From patchwork Fri Jan 13 14:26:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andreas_H=C3=A5kon?= X-Patchwork-Id: 2211 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp208307vsb; Fri, 13 Jan 2017 06:26:55 -0800 (PST) X-Received: by 10.223.169.112 with SMTP id u103mr12144858wrc.166.1484317614563; Fri, 13 Jan 2017 06:26:54 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c48si11390489wra.290.2017.01.13.06.26.53; Fri, 13 Jan 2017 06:26:54 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@protonmail.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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6B7D068A3DA; Fri, 13 Jan 2017 16:26:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.protonmail.ch (mail1.protonmail.ch [185.70.40.18]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 63FC468A3A7 for ; Fri, 13 Jan 2017 16:26:37 +0200 (EET) Received: from B09B-1 (localhost [127.0.0.1]) by mail1.protonmail.ch (Postfix) with ESMTP id 8FFA2833F2 for ; Fri, 13 Jan 2017 09:26:41 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1484317601; bh=BFD6ro9YdDztTSGrZtANNmU1PIaXv+Tu9TyILue2Ke8=; h=Date:To:From:Reply-To:Subject:Feedback-ID:From; b=nmL75fy+v59N5TaM8W8HjESfiAQpUdEdAEqjftvElVWl8LxIKXmTWbGuJ1WF+9rZQ wFJKgPoxdUCGv7+V22IIC6Wqxmy0HG+KDrRE2ajse9MHJ5hlr39LB1PhMW9PktQc8O FLXdXB474zc1AYq8JD+rCYqzUhZpT1NmvLZ42yMk= Date: Fri, 13 Jan 2017 09:26:16 -0500 To: FFmpeg development discussions and patches From: =?UTF-8?Q?Andreas_H=C3=A5kon?= Message-ID: Feedback-ID: Mx8CaiV20jk_fqXDN0fFpg3vRaGkb9VCTrYRnZNHwEija3aOdqvFspzl6ODkmHrlSKJSx29p-LzkuvS_96L02A==:Ext:ProtonMail MIME-Version: 1.0 X-Spam-Status: No, score=-3.0 required=4.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE, MIME_BASE64_BLANKS,URIBL_BLOCKED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail1.protonmail.ch X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH 1/1] avformat: Add alignment mode to Pro-MPEG 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, The Pro-MPEG FEC module has troubles with some receivers. This patch fixes this problem incorporating the option for selecting different alignment modes. The problem is related to the alignment of the COLUMN FEC packets (aka. when send the packet). Current block-alignment implies a delay of quasi-the-length of the matrix size. Then several receivers discard the column fec packets when they start to receive DATA packets from the next matrix. Three different modes are possible (only two implemented): - Mode 0: No alignment. When a new row starts, and the column is complete, then send the COL FEC packet. This is the default behaviour for several devices. However, this mode is prone to errors when they happen in the last row; but it's still more compatible. - Mode 1: COL alignment. This is the default and already implemented alignment. COL FEC packets are send equispaced when processing the next matrix. Implies more delay in the receiver and a double-size buffer. - Mode 2: ROW alignment. This is unimplemented. After compute each column it's send the COL FEC packet. Very similar to mode 0. Please, review the code. I do several tests with professional equipment. Results improves using mode 0 with some receivers. A.H. From ef52c6b87d38f790280ab1988287e71ef31ecdf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20H=C3=A5kon?= Date: Fri, 13 Jan 2017 15:09:07 +0100 Subject: [PATCH 1/1] avformat: Add alignment mode to Pro-MPEG --- doc/protocols.texi | 3 +++ libavformat/prompeg.c | 27 ++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/doc/protocols.texi b/doc/protocols.texi index e887b75..b9da67b 100644 --- a/doc/protocols.texi +++ b/doc/protocols.texi @@ -542,6 +542,9 @@ The number of columns (4-20, LxD <= 100) @item d=@var{n} The number of rows (4-20, LxD <= 100) +@item align=@var{n} +Alignment mode for column FEC packets (0=none, 1=COL (default), 2=ROW) + @end table Example usage: diff --git a/libavformat/prompeg.c b/libavformat/prompeg.c index 9770a91..a040c43 100644 --- a/libavformat/prompeg.c +++ b/libavformat/prompeg.c @@ -105,6 +105,7 @@ typedef struct PrompegContext { PrompegFec **fec_arr, **fec_col_tmp, **fec_col, *fec_row; int ttl; uint8_t l, d; + uint8_t align; uint8_t *rtp_buf; uint16_t rtp_col_sn, rtp_row_sn; uint16_t length_recovery; @@ -124,6 +125,7 @@ static const AVOption options[] = { { "ttl", "Time to live (in milliseconds, multicast only)", OFFSET(ttl), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = E }, { "l", "FEC L", OFFSET(l), AV_OPT_TYPE_INT, { .i64 = 5 }, 4, 20, .flags = E }, { "d", "FEC D", OFFSET(d), AV_OPT_TYPE_INT, { .i64 = 5 }, 4, 20, .flags = E }, + { "align", "Alignment mode: 0=none; 1=COL (default); 2=ROW", OFFSET(align), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 2, .flags = E }, { NULL } }; @@ -430,9 +432,28 @@ static int prompeg_write(URLContext *h, const uint8_t *buf, int size) { s->fec_col_tmp[col_idx]->bitstring, s->bitstring_size); } - // FEC (column) send block-aligned - if (!s->first && s->packet_idx % s->d == 0) { - col_out_idx = s->packet_idx / s->d; + // FEC (column) send + col_out_idx = -1; + if (!s->first) { + switch (s->align) { + case 0: + // non-aligned + if (s->packet_idx <= s->l) + col_out_idx = s->packet_idx - 1; + break; + case 2: + // ROW block-aligned + // un-implemented! + case 1: + default: + // COL block-aligned + if (s->packet_idx % s->d == 0) + col_out_idx = s->packet_idx / s->d; + break; + } + + } + if (col_out_idx >= 0) { if ((ret = prompeg_write_fec(h, s->fec_col[col_out_idx], PROMPEG_FEC_COL)) < 0) goto end; written += ret;