From patchwork Mon Sep 4 14:21:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maksym Veremeyenko X-Patchwork-Id: 4981 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp3172368jao; Mon, 4 Sep 2017 07:21:26 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5q1UZFTkJNFTTtTPcGgZlISPH91D70PKfhlJYBebNTFWVIBzZo5s5ETBcGcMtYipuFT1sE X-Received: by 10.28.143.205 with SMTP id r196mr372123wmd.144.1504534886546; Mon, 04 Sep 2017 07:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504534886; cv=none; d=google.com; s=arc-20160816; b=PU0vo1Q85IvXnigl6eNTQzI9rzlVgBOA8ju0sxaMIfnazvCgttihNQuJGbCcNjH4/f fzmvNVvvI9URBDvE2PiDTCBLko1nPsK8dcwrPuIC9CqFCzMoAT2p1BcuUVN9MfoIjW6w wk2VjTPRJpNM3txgKscKXD5Ns+qrtlJOER/YvvZiYNcT6DoopBjUoRuDlosGHEAYeJYj c3STPTISgc/9Gsjt9oAEuUkWvg/zZd6LYZ0UGv02y5SSjNwolQe+qvq0+3bHDN0wXqM1 mnpehVypFSO6zlPznADxWpzcfb2wJ7xbm8D3xv4DK04fzw65z1/YgN8+crBDU66Dx3iy mPrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-language:mime-version:user-agent:date:message-id:to:from :delivered-to:arc-authentication-results; bh=0pyGOrBnIvmmD6SKyxWw47EQV5LtvsIEzai2bKhGFok=; b=r7ZmvmWqVj3iO3DdZtIwET147nWIIkd3lo3R0ZhiBbr851ztLTspmThBF7PjBk2XHN /7rvBpXjcg5tFbe8n6TzAeyu375H376RpBdjY0xfIpMIxPr1DzOJYxAOMO5fKfGxUmvG FK4bFSvgivkpecH9UMQu5E7qySLBsrKHlL1w5SAm8u+5ltNUXz+ji2k4for4N8bYjBdm uXlRk0KM7IYpqBJr70k08va3iA0IUGBBfAXtVjY4g4dkm59NgCWj202c9ophTjtDOVw4 659izflArOARob9Y7s16Sdx8Mb8fqc7r+IYU5SWECMLsSjhkrOcBMElgdaU65OpC30Dq /gfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 18si5298968wmp.214.2017.09.04.07.21.26; Mon, 04 Sep 2017 07:21:26 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 89C9868A24B; Mon, 4 Sep 2017 17:21:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from kazbek.m1stereo.tv (mail.m1stereo.tv [91.244.124.37]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E6EE9689B00 for ; Mon, 4 Sep 2017 17:21:15 +0300 (EEST) Received: from [10.1.5.65] (dev-3.internal.m1stereo.tv [10.1.5.65]) by kazbek.m1stereo.tv (8.14.4/8.14.4) with ESMTP id v84ELHDo011136 for ; Mon, 4 Sep 2017 17:21:18 +0300 From: Maksym Veremeyenko To: ffmpeg-devel@ffmpeg.org Message-ID: <1bff8306-b28d-b7b9-22f0-4a5367412159@m1stereo.tv> Date: Mon, 4 Sep 2017 17:21:17 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 Content-Language: en-US Subject: [FFmpeg-devel] [PATCH] lavd: rework interlacing setting on NewTek NDI output X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Hi, move interlacing setting of NDI frame to packet sending function and take care on field order AV_FIELD_UNKNOWN - take a interlacing settings from avframe->interlaced_frame diff --git a/libavdevice/libndi_newtek_enc.c b/libavdevice/libndi_newtek_enc.c index be0b271..9a76450 100644 --- a/libavdevice/libndi_newtek_enc.c +++ b/libavdevice/libndi_newtek_enc.c @@ -158,6 +158,7 @@ static int ndi_write_video_packet(AVFormatContext *avctx, AVStream *st, AVPacket { struct NDIContext *ctx = avctx->priv_data; AVFrame *avframe, *tmp = (AVFrame *)pkt->data; + AVCodecParameters *c = st->codecpar; if (tmp->format != AV_PIX_FMT_UYVY422 && tmp->format != AV_PIX_FMT_BGRA && tmp->format != AV_PIX_FMT_BGR0 && tmp->format != AV_PIX_FMT_RGBA && @@ -188,6 +189,15 @@ static int ndi_write_video_packet(AVFormatContext *avctx, AVStream *st, AVPacket ctx->video->line_stride_in_bytes = avframe->linesize[0]; ctx->video->p_data = (void *)(avframe->data[0]); + if (c->field_order == AV_FIELD_UNKNOWN) + ctx->video->frame_format_type = tmp->interlaced_frame + ? NDIlib_frame_format_type_interleaved + : NDIlib_frame_format_type_progressive; + else + ctx->video->frame_format_type = c->field_order == AV_FIELD_PROGRESSIVE + ? NDIlib_frame_format_type_progressive + : NDIlib_frame_format_type_interleaved; + av_log(avctx, AV_LOG_DEBUG, "%s: pkt->pts=%"PRId64", timecode=%"PRId64", st->time_base=%d/%d\n", __func__, pkt->pts, ctx->video->timecode, st->time_base.num, st->time_base.den); @@ -358,9 +368,6 @@ static int ndi_setup_video(AVFormatContext *avctx, AVStream *st) ctx->video->yres = c->height; ctx->video->frame_rate_N = st->avg_frame_rate.num; ctx->video->frame_rate_D = st->avg_frame_rate.den; - ctx->video->frame_format_type = c->field_order == AV_FIELD_PROGRESSIVE - ? NDIlib_frame_format_type_progressive - : NDIlib_frame_format_type_interleaved; if (st->sample_aspect_ratio.num) { AVRational display_aspect_ratio;