From patchwork Thu Feb 3 01:01:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Keroulas X-Patchwork-Id: 34079 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp2040197iov; Wed, 2 Feb 2022 17:02:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxLAceu94nv4uldNaXChHuNG5hX7YBZIZe0DpUa2+5C8Z4JZT36V4x7IZi0gL2cQ2IfncPQ X-Received: by 2002:a05:6402:4385:: with SMTP id o5mr32974965edc.48.1643850159380; Wed, 02 Feb 2022 17:02:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643850159; cv=none; d=google.com; s=arc-20160816; b=wboWA10PTh4seuXZytkXDLFBWgE2xSKYOlnNBR+qDTUFZ/jNNkmB8xjsIADQoGlly+ Ltz809/QlHKnh+RmBGd+jgti1+6YYreID8zXqTgkdWwKgYPJCz2BsZvqz/cB3aOqh8/6 3stoZbIcVNYD4/fGUTZQl/EDNv+kt5OfOGkG6Gj4bjZVtnDSK1lIEcmZssZqiW5j3A3B kbVW1Jj6nK0kkpaVWuivnFTjZAPBvcy5GRSLiKueWVt2BXbiOh7Y40z1z/Z08c7fD1rh b4jvAbnZcraUqx7cJN4hGCNLK4pAPH5809UI0gRrHvMidv8ZRiFdPSeyytbZqMNV8p+/ QKwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=0w9SClMI6ilk+gQ+5skzmEC9n6/od2ZpMsYxf0DUQuY=; b=L90NnT8XIr8Fkd4QDDU08ECoLsRf429HnZ0H7KrjN91Wtwdj53u1vVWrxBjDPdX0Tr 9ZmkbHeJhRMCAv4GeHAbE7NEqsf11QF/XZAjEgt2ZbM+EVGJH+Rjd5KRRfOPAttlbn2U IVN8tlepF9azo+Zn1rMd2X4ydexWIpzAe6HognTZ3An3hjDymS5f6/qJx1907Oe0N5RD mngalgqRD4AMJAy33kbyVnt/d824WcoBXDzYuzsv1OYeFj4D8BFs5fUq4L1Hs/HNeRvS p7gTsao8YIY0788kGufW1CCcBI4Kf8JOKau9tpEyJJjMniygIXGdSJCkmEKmG5mOPcKj 50nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@radio-canada.ca header.s=mimecast20211019 header.b=ANpYOQUD; 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 bs11si11494957edb.331.2022.02.02.17.02.38; Wed, 02 Feb 2022 17:02:39 -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=@radio-canada.ca header.s=mimecast20211019 header.b=ANpYOQUD; 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 B55C468AEBC; Thu, 3 Feb 2022 03:02:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from eu-smtp-delivery-104.mimecast.com (eu-smtp-delivery-104.mimecast.com [185.58.85.104]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CF76B68AC71 for ; Thu, 3 Feb 2022 03:02:28 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=radio-canada.ca; s=mimecast20211019; t=1643850147; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3BR69C6CgDHXKIVKn4mS1Izyfyyk4XpbjshKo4jb97U=; b=ANpYOQUDD33DgZVSoBOAEHVRzBig3lc/qydfyfU1y+u24mQgHovbLxb2ZH9CUF8zfLXkbL ZvSC/b7JzHljBHcfQsfAqYbo61EzB4HcPT4eva1sU9b2cYAh2l9rPyZgDhHrPcdNLY4J7z HU+uow8/YMybCabgwWPkoF4MFqFgTe0= Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id uk-mta-20-Z75wclrsP7O5nqHekK67fg-1; Thu, 03 Feb 2022 01:02:26 +0000 X-MC-Unique: Z75wclrsP7O5nqHekK67fg-1 Received: by mail-io1-f70.google.com with SMTP id y4-20020a056602200400b006101b618529so706894iod.19 for ; Wed, 02 Feb 2022 17:02:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=TxYkFcx+HP62hawpxMHjtTiLKOHwfWy0wwycYsmjgfY=; b=4k/g2KfNdjDmCxJRLJjIHiDTWd6hpkemjoUH7Oth8quNvp3y4UJXWZofCimVziFvoE taSaYAs0HhZ68e121WpKKszpM8oc6R2+X3nqcT2bPaR3N/zm+zVXmi0YnTxtJFTWj4PG BLnwDr95MDYZBqOlJMk05tuE8h3lgAUCRIKwDnyKNVd8qK08Kew5091i1RclKi8Hyz7W P9Rflamv0rsKXYhAe2R/wteippdGdByLgozwiobBF8ULKwoForfXuU/7FQeO3xk8m2FJ JqXsIra2f8VSNFtyBMopMTcqdWO7S8wVqWN8AAXp04sX0P7X/Cmxumc7jrfp1FTf8x7y 0FZA== X-Gm-Message-State: AOAM532+TUcJsmzh/G1LIpdqYpSyn8tWC0BNUk8Fz3Zza9IROGUYlHmc HnoO34BDCIhHuuEzDlyU1fR8aOynmz8m82YWreqLV7kkSnrgAySfvUBEPqm6UrBvJAZD59HQhxz ncAQuCrK3m4v2ru0= X-Received: by 2002:a02:3b67:: with SMTP id i39mr16145203jaf.50.1643850144842; Wed, 02 Feb 2022 17:02:24 -0800 (PST) X-Received: by 2002:a02:3b67:: with SMTP id i39mr16145192jaf.50.1643850144487; Wed, 02 Feb 2022 17:02:24 -0800 (PST) Received: from localhost.localdomain ([159.33.64.194]) by smtp.gmail.com with ESMTPSA id q12sm6269420ilt.15.2022.02.02.17.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Feb 2022 17:02:23 -0800 (PST) From: Patrick Keroulas To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Feb 2022 20:01:55 -0500 Message-Id: <20220203010155.1098124-1-patrick.keroulas@radio-canada.ca> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUK104A247 smtp.mailfrom=patrick.keroulas@radio-canada.ca X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: radio-canada.ca Subject: [FFmpeg-devel] [PATCH] avformat/rtpdec_rfc4175: fix interlace format X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Patrick Keroulas , lance.lmwang@gmail.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: bVkx+DxFJxHA In previous state, a new frame was allocated on each timestamp step, i.e. each frame/field transition. However, for interlace, a new frame should be allocated on 1st field, completed with the 2nd and finally freed. This commit fixes the frame allocation and the detection of missing RTP markers. Signed-off-by: Patrick Keroulas --- libavformat/rtpdec_rfc4175.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c index 8e73c07838..83abe499f8 100644 --- a/libavformat/rtpdec_rfc4175.c +++ b/libavformat/rtpdec_rfc4175.c @@ -234,20 +234,21 @@ static int rfc4175_handle_packet(AVFormatContext *ctx, PayloadContext *data, uint8_t *dest; if (*timestamp != data->timestamp) { - if (data->frame) { + if (data->frame && (!data->interlaced || data->field)) { /* - * if we're here, it means that two RTP packets didn't have the - * same timestamp, which is a sign that they were packets from two - * different frames, but we didn't get the flag RTP_FLAG_MARKER on - * the first one of these frames (last packet of a frame). - * Finalize the previous frame anyway by filling the AVPacket. + * if we're here, it means that we missed the cue to return + * the previous AVPacket, that cue being the RTP_FLAG_MARKER + * in the last packet of either the previous frame (progressive) + * or the previous second field (interlace). Let's finalize the + * previous frame (or pair of fields) anyway by filling the AVPacket. */ av_log(ctx, AV_LOG_ERROR, "Missed previous RTP Marker\n"); missed_last_packet = 1; rfc4175_finalize_packet(data, pkt, st->index); } - data->frame = av_malloc(data->frame_size); + if (!data->frame) + data->frame = av_malloc(data->frame_size); data->timestamp = *timestamp;