[FFmpeg-devel] [PATCH] lavd: rework interlacing setting on NewTek NDI output
Maksym Veremeyenko
verem at m1stereo.tv
Mon Sep 4 17:21:17 EEST 2017
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
--
Maksym Veremeyenko
-------------- next part --------------
From 93dc2a881674d9371963d4555f81c000ceb09bdc Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <verem at m1.tv>
Date: Mon, 4 Sep 2017 09:50:22 -0400
Subject: [PATCH 3/3] lavd: rework interlacing setting on NewTek NDI output
---
libavdevice/libndi_newtek_enc.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
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;
--
1.8.3.1
More information about the ffmpeg-devel
mailing list