From patchwork Tue Apr 10 21:21:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Keroulas X-Patchwork-Id: 8385 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.1.70 with SMTP id c67csp78606jad; Tue, 10 Apr 2018 16:47:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+DgizA6ZDmYYKUx+Zh0adDhMZueCzLfS3yDSl9t5Kz2bcfrQmD4I1XYw61WMkmT+GA8YQe X-Received: by 10.223.157.129 with SMTP id p1mr1538295wre.281.1523404047562; Tue, 10 Apr 2018 16:47:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523404047; cv=none; d=google.com; s=arc-20160816; b=HfXeJbxqbdpJUFCH05FvZf1aqZj0FMOFM4MkqD98TGoV/edahWxGWYz5Drq267POcq 6db8N+hrQL6O8XRB0G8gUgMzjKzmqbxhSJjXs5bK89hdsQrRdwY4TkAgMakaSrBSd5Sn 6iqxJzgE3VCCD2aK/qoDp6Y3DWl5E4uuVkIW9WQgc24x0jRwRj9cfzioh35aPna3D+bf uix1r16+pTUkkdTCGKoSqXHlU3JQOJjNk9Wm1P6JKtOiRYAc4qTemEKnw/LSX+MKcLn5 6u4gCDdT/q6khhenjMFbEYLwEDuUTYCCxbFQyvhVdPPKgq1L09iK7xC0xdwk1c2DYksx 9t0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=wz/JMbmPuNwHqqIodDUdp/zuPlQn+/4hcI95yW392Nw=; b=rlFJe8E11axTWPGfv/NNv3KdmnIs+WYxbABKKCstnpIg/NRZfFn4m7J2iGKZr0fmg6 mOmLkFJVV2II2Z990g9RMrQCsEjRQfkCQ3SNPWDSOehroRgpLpGvIUdXnnRhpgUBFlVX iZQr26VelV0xDglhmQ1kbyawLyiqkC1rTWO2T8rPrMd1cCalW+3sVfCqBYLGyriK0mNN YzpQEwM55MeA6IU8PhWwCpxlS1HcpHSjDBw2x0+T3Qss7edXZR0V9cot4iMqsYVDDgYk dyxz/hrK65s2aIK0R18RrnLTR6R2DGDePxl9XjEmoFZY+takck9TTnnDDyIehpArK3ol XBrA== 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 p2si2741258wrb.169.2018.04.10.16.47.27; Tue, 10 Apr 2018 16:47:27 -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 5E1AE68A143; Wed, 11 Apr 2018 02:46:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3243968A09E for ; Wed, 11 Apr 2018 00:21:20 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 6EA599C354F for ; Tue, 10 Apr 2018 17:21:42 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id KqV7C4UDZOwq; Tue, 10 Apr 2018 17:21:42 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 027A99C3343; Tue, 10 Apr 2018 17:21:42 -0400 (EDT) X-Virus-Scanned: amavisd-new at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id trCJeO4fLeZD; Tue, 10 Apr 2018 17:21:41 -0400 (EDT) Received: from pkeroulas.mtl.sfl (unknown [192.168.50.171]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id C8B899C354E; Tue, 10 Apr 2018 17:21:41 -0400 (EDT) From: Patrick Keroulas To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Apr 2018 17:21:37 -0400 Message-Id: <1523395297-13466-3-git-send-email-patrick.keroulas@savoirfairelinux.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523395297-13466-1-git-send-email-patrick.keroulas@savoirfairelinux.com> References: <1523395297-13466-1-git-send-email-patrick.keroulas@savoirfairelinux.com> X-Mailman-Approved-At: Wed, 11 Apr 2018 02:46:48 +0300 Subject: [FFmpeg-devel] [PATCH v1 3/3] avformat/rtpdec_rfc4175: handle interlace format 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 Cc: Damien Riegel MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Damien Riegel In order to handle the interlaced formats, the demuxer has only a few things to do: - parse the SDP correctly and propagate the information - check the field bit in the RFC4175 header, and pass that information to the decoder In interlaced mode, received data only consist of fields, and their heights are half of the frame size, so some adjustments must be done here and there to take that into account. Signed-off-by: Damien Riegel --- libavformat/rtpdec_rfc4175.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c index e9c62c1..55a36eb 100644 --- a/libavformat/rtpdec_rfc4175.c +++ b/libavformat/rtpdec_rfc4175.c @@ -31,6 +31,8 @@ struct PayloadContext { int depth; int width; int height; + int interlaced; + int field; uint8_t *frame; unsigned int frame_size; @@ -65,10 +67,18 @@ static int rfc4175_parse_format(AVStream *stream, PayloadContext *data) return AVERROR_INVALIDDATA; } + if (data->interlaced) + stream->codecpar->field_order = AV_FIELD_TT; + else + stream->codecpar->field_order = AV_FIELD_PROGRESSIVE; + stream->codecpar->format = pixfmt; stream->codecpar->codec_tag = tag; stream->codecpar->bits_per_coded_sample = bits_per_sample; - data->frame_size = data->width * data->height * data->pgroup / data->xinc; + if (data->interlaced) + data->frame_size = data->width * (data->height / 2) * data->pgroup / data->xinc; + else + data->frame_size = data->width * data->height * data->pgroup / data->xinc; return 0; } @@ -85,6 +95,8 @@ static int rfc4175_parse_fmtp(AVFormatContext *s, AVStream *stream, data->sampling = av_strdup(value); else if (!strncmp(attr, "depth", 5)) data->depth = atoi(value); + else if (!strncmp(attr, "interlace", 9)) + data->interlaced = 1; return 0; } @@ -131,7 +143,11 @@ static int rfc4175_finalize_packet(PayloadContext *data, AVPacket *pkt, av_freep(&data->frame); } + /* In the packet header, the field is set to 0 for top field + * and 1 for bottom */ + pkt->flags |= data->field ? 0 : AV_PKT_FLAG_TOP_FIELD; data->frame = NULL; + data->field = 0; return ret; } @@ -141,7 +157,7 @@ static int rfc4175_handle_packet(AVFormatContext *ctx, PayloadContext *data, const uint8_t * buf, int len, uint16_t seq, int flags) { - int length, line, offset, cont; + int length, line, offset, cont, field; const uint8_t *headers = buf + 2; /* skip extended seqnum */ const uint8_t *payload = buf + 2; int payload_len = len - 2; @@ -194,11 +210,14 @@ static int rfc4175_handle_packet(AVFormatContext *ctx, PayloadContext *data, return AVERROR_INVALIDDATA; length = (headers[0] << 8) | headers[1]; + field = (headers[2] & 0x80); line = ((headers[2] & 0x7f) << 8) | headers[3]; offset = ((headers[4] & 0x7f) << 8) | headers[5]; cont = headers[4] & 0x80; headers += 6; + data->field = field; + if (length % data->pgroup) return AVERROR_INVALIDDATA;