From patchwork Tue Aug 14 03:50:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 9983 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp3872789jad; Mon, 13 Aug 2018 20:51:04 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwiJrdt5UJ29KAvzq1BrSUF72fvIuMxMnomXo0shVYZdD1/qeQNkIFUp/l/6F8Plc6Izqos X-Received: by 2002:adf:9486:: with SMTP id 6-v6mr8905764wrr.257.1534218664611; Mon, 13 Aug 2018 20:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534218664; cv=none; d=google.com; s=arc-20160816; b=cMH6GXwS9H58bapqy4e+i7u0shFCN3G5+LmccV7Bd4nLACAhqKnlZcbKjCf3B5laxM AP77MrobUIRR0qNIwMySMM1Yy5h7PdSzo6iAxvJKRDqzPivNqa+FKSG2z9GWn9T71F/5 Tnk7EeQxLHAUKbAXnDebQ5khPiRKy5xtzTcNESm0Sx8z2eNx4o3gLgnw/1OArfB6L6ol AjMeKXWRXCI7ujJKFxQQJKYe7PF9Ew2SPybf0rBVGsWhEdrgN1TlIQgRTiNZBROB51di ShLHfjOv1mjSsXY8ofSzJFE8VW8XIIV9ZvRMi32zinQlVNXWGN7gbC7VS/vw5KsVOtqX xdkw== 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:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:to:dkim-signature:delivered-to :arc-authentication-results; bh=3q9SzI2mISs+DHRRHTCMlBeCBY7RuhlzrpiEkWE8T58=; b=gqxrXnTw8OITQ/AjSXQwNLnVwDgJsV82G17ZO2Ox2JF2dJex0agZTkbqYzrA5qgMMb HZXKpqbWI5Iuj07n3LZMmpU+OwzTEKG7Z8gmTVXYDxnbeQxL9/Dg0Q52Z1yw+zsRAvg1 f9nNA41ni02UyHljHuFhj+P2Vll461jq7KZiOjU2gd4ypkiQ9gQKyVVOPpjyIrhUrVrd Klf/sQS/gsfx9FSOqNW0HDf4AXZJSbopaFDYqCZiqUgBMYpIBbxhMcpZCC/cYPU868em OVqUpcQ1rbp9v6uTO8cRhn4dqtljbmalNZsqpxrDqRkh/PAnu97OxSeSR+8YbH2bKLCa rNjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="o6u18/rv"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w18-v6si12682425wrk.170.2018.08.13.20.51.02; Mon, 13 Aug 2018 20:51:04 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b="o6u18/rv"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7428068A552; Tue, 14 Aug 2018 06:50:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f193.google.com (mail-qt0-f193.google.com [209.85.216.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 84D1A68A389 for ; Tue, 14 Aug 2018 06:50:31 +0300 (EEST) Received: by mail-qt0-f193.google.com with SMTP id b15-v6so19756081qtp.11 for ; Mon, 13 Aug 2018 20:50:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:openpgp:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=O08Q1kF9nuO+Q/qV91qiJWG7S1kRX6Rr3wELNMXVBJA=; b=o6u18/rvullDuyQK8XiNAPpnVMRwRUFSh+m/P8cKvcwTuGSDWcJUnK826UGb0HPHhb wh3qpLohHDayT4A16ulgMQRfB2bhU3+CszfAb4cvu/EMILbInOtKdcZ3Q7cwWK39E95a zdAJbcDcfP+RynIZGw+uMOI4FECRCD+QcNhiL592c4KwWL0pN0XzL++Zpz0PM6WNd0jX eCoGGuOsFuxxDZOxph73GLXtOJ7xLV750sfs9LctiXq70R8qgHykIP/qHVKY7ua2pVsy KH+5NXjAMuBgHkQCuaSOaZ6aJfH8MaFHtcOI3/OtC78CCZYr2Vm+8wnQiungfhEx/x4w /N7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=O08Q1kF9nuO+Q/qV91qiJWG7S1kRX6Rr3wELNMXVBJA=; b=ZblAYuDjqZ6zBtP3FUUh8p42oAJTTVCRRIygrik5lF7uhoC9l1ww80+ND9Htn0fRnl JUZleGoyBhxY48fxe26U+QHSgVEgepYJEKKc4OTLUNHD1BzooHTtp2el8yU1QTUF4fTs jmodlhrudqeD4/EpMYZnVLV17jm+w3eJri1PKgeyprXvjs8jz1aEHieyCj898FKXwmAu VHWF4TJu18dhFcX8wdAqUInQ7HyR681YNmT/5X/mS4zO0za2qm8c8xZ16NsY6sSmj9j1 fjaHhmcn+Ip42nWiFCLx6DZ+wJjIdxjByGZlZP3LRyqh9h12SPBXWYZY3/3YyfkKgSLX Viag== X-Gm-Message-State: AOUpUlFVNv248y2THRH75Rh9GP3schAHwZEpAytqcT4lJeZ7FcKxczFD HB4tAubIZmMDAJBUj+dFfz6Jr8Kg X-Received: by 2002:ac8:505:: with SMTP id u5-v6mr170954qtg.114.1534218653713; Mon, 13 Aug 2018 20:50:53 -0700 (PDT) Received: from [192.168.0.4] ([190.188.171.140]) by smtp.gmail.com with ESMTPSA id z22-v6sm9275878qki.59.2018.08.13.20.50.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Aug 2018 20:50:53 -0700 (PDT) To: ffmpeg-devel@ffmpeg.org References: From: James Almer Openpgp: preference=signencrypt Message-ID: Date: Tue, 14 Aug 2018 00:50:49 -0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Subject: Re: [FFmpeg-devel] [PATCH] avformat/matroska: Parse generic encryption info from packets. 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" On 7/12/2018 8:45 PM, Jacob Trimble wrote: > I am currently seeing a problem with this when using Opus audio. In > read_frame_internal, it will try to parse the resulting packet. For > video, which uses subsample encryption, it is able to parse the > headers; but for Opus, which uses full-sample encryption, it fails to > parse the headers. This causes the read_frame_internal to drop the > packet. > > I have traced a workaround to opus_parse in opus_parser.c: instead of > setting poutbuf to NULL, set it to the buffer and just pass the packet > to the app to handle it. The frame will be decrypted before passing > to the decoder. I can't just disable parsing in the demuxer because I > want to parse the packets for clear content and when using subsample > encryption. > > Does anyone have any other ideas to work around this? Is there a way > to allow parsing but ignore errors? Try the attached diff to see if it fixes the issue (It makes the parser not bother trying to assemble packets from what could be incomplete data if the source is a demuxer that guarantees the propagation of complete packets). diff --git a/libavcodec/opus_parser.c b/libavcodec/opus_parser.c index 28b0933900..e8d157356c 100644 --- a/libavcodec/opus_parser.c +++ b/libavcodec/opus_parser.c @@ -170,6 +170,9 @@ static int opus_parse(AVCodecParserContext *ctx, AVCodecContext *avctx, ParseContext *pc = &s->pc; int next, header_len; + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { + next = buf_size; + } else { next = opus_find_frame_end(ctx, avctx, buf, buf_size, &header_len); if (s->ts_framing && next != AVERROR_INVALIDDATA && @@ -184,6 +187,7 @@ static int opus_parse(AVCodecParserContext *ctx, AVCodecContext *avctx, *poutbuf_size = 0; return buf_size; } + } *poutbuf = buf + header_len; *poutbuf_size = buf_size - header_len;