From patchwork Thu Sep 15 20:36:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasi Inguva X-Patchwork-Id: 595 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp99722vsd; Thu, 15 Sep 2016 13:42:54 -0700 (PDT) X-Received: by 10.194.90.239 with SMTP id bz15mr10439526wjb.146.1473972174412; Thu, 15 Sep 2016 13:42:54 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j83si4776916wmj.59.2016.09.15.13.42.52; Thu, 15 Sep 2016 13:42:54 -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=@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 D1789689E1E; Thu, 15 Sep 2016 23:42:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f178.google.com (mail-pf0-f178.google.com [209.85.192.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BE41A689D0D for ; Thu, 15 Sep 2016 23:42:30 +0300 (EEST) Received: by mail-pf0-f178.google.com with SMTP id p64so20085409pfb.1 for ; Thu, 15 Sep 2016 13:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WlJQcu9Obd3aunE37p/+APOub2QsH8xsfaAcYIyS+ww=; b=RSJN939ZnKl6+OEBcg4A4zqoZOUcZWxznNhlm9fAA0TaLsFfSvABNASeGJo2fuOqnW ImjNtxSFVwCj7EnZ1UmhCFHbQ8qAQQWGlm6At89V+dfk+59xxCoH197nCVMajCcXZJu6 6NwiYu/DKnpVwZKq04xFabEqmVcklhhHT0VM7C5cFWofb+1rv2eCnRp3uCVSqI3NFp6u TUW6kbUxIOj0GeyoHeAbiddePIN1GZBCZBEBpQOhE1uBVY+19lO9hgST8XG4t1NLM91f gc0RHabMlZX4NBvECYndxlci78MjISyvdsNVnhwEqtpk/TRHDeM4Pns+GryvwKzDBoAa nNvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WlJQcu9Obd3aunE37p/+APOub2QsH8xsfaAcYIyS+ww=; b=KbdUfSmATXdz6co46oNCcvroGiIM7UdpzCgxs1J09Fhtps8E6BHLxoNvpdJrUsUYXl wIaJRrJ8cfOVtHqwDG/rGgob4ueAgSV479G7L93Kge0xUOTeSRVK9edMSP4kIsRSsc2I dTaNuvqhlZFxggPdLF2k3bB3Y/UrQsqd7RLwWFQSPnGtRuUTO8On0Y1UGn6z688IZbV9 Fn5pLGeH1P1cHA/uaVtzl7IvBuVC5odCdfgRMPVBOI13W0I4SwmOimIO7enVspJRAlwm cC2NE4B+3/9P4NMzhciiLMJzX8xo7/Ul/YKI4dwBFrhhacg1OWeO5zBFcNC7GujMrJjz GODA== X-Gm-Message-State: AE9vXwNw/zTY1hgV9+oUAN7jraLj0bK2eJytNdISA4hAI45y5oLxfL7AP0Pq6bDTba4Lt0K2 X-Received: by 10.98.0.69 with SMTP id 66mr17608070pfa.140.1473971828239; Thu, 15 Sep 2016 13:37:08 -0700 (PDT) Received: from isasi.mtv.corp.google.com ([172.27.82.89]) by smtp.gmail.com with ESMTPSA id b64sm47082466pfa.82.2016.09.15.13.37.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Sep 2016 13:37:07 -0700 (PDT) From: Sasi Inguva To: ffmpeg-devel@ffmpeg.org Date: Thu, 15 Sep 2016 13:36:16 -0700 Message-Id: <1473971779-27524-3-git-send-email-isasi@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1473971779-27524-1-git-send-email-isasi@google.com> References: <1473971779-27524-1-git-send-email-isasi@google.com> Subject: [FFmpeg-devel] [PATCH 3/6] lavc: Add a flag in AVPacket to discard packet after decoding. Discard frames after decoding based on the flag. 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: Sasi Inguva MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Sasi Inguva --- libavcodec/avcodec.h | 6 ++++++ libavcodec/utils.c | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 01f9b29..db1061d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1621,6 +1621,12 @@ typedef struct AVPacket { } AVPacket; #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted +/** + * Flag is used to discard packets which are required to maintain valid + * decoder state but are not required for output and should be dropped + * after decoding. + **/ +#define AV_PKT_FLAG_DISCARD 0x0004 enum AVSideDataParamChangeFlags { AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 0f6d0e7..4734a70 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -784,6 +784,12 @@ int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) } } add_metadata_from_side_data(pkt, frame); + + if (pkt->flags & AV_PKT_FLAG_DISCARD) { + frame->flags |= AV_FRAME_FLAG_DISCARD; + } else { + frame->flags = (frame->flags & ~AV_FRAME_FLAG_DISCARD); + } } else { frame->pkt_pts = AV_NOPTS_VALUE; av_frame_set_pkt_pos (frame, -1); @@ -2247,7 +2253,9 @@ fail: if(ret == tmp.size) ret = avpkt->size; } - + if (picture->flags & AV_FRAME_FLAG_DISCARD) { + *got_picture_ptr = 0; + } if (*got_picture_ptr) { if (!avctx->refcounted_frames) { int err = unrefcount_frame(avci, picture); @@ -2343,6 +2351,11 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, frame->sample_rate = avctx->sample_rate; } + + if (frame->flags & AV_FRAME_FLAG_DISCARD) { + *got_frame_ptr = 0; + } + side= av_packet_get_side_data(avctx->internal->pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size); if(side && side_size>=10) { avctx->internal->skip_samples = AV_RL32(side);