From patchwork Tue Apr 21 04:48:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 19129 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id B76AD44A2CB for ; Tue, 21 Apr 2020 07:49:14 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A6BAB68B801; Tue, 21 Apr 2020 07:49:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E849568B927 for ; Tue, 21 Apr 2020 07:49:05 +0300 (EEST) Received: by mail-pl1-f181.google.com with SMTP id w3so4815484plz.5 for ; Mon, 20 Apr 2020 21:49:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uY/6Z36Wpe8Rhmjf912uWmtdwXpqjAAYaeOTnRmS5HE=; b=dqx+2x8MSb/9CrFV/ckNO6G4WFYV7pX84nOj8KCFRzqq0W9yXRJ/SAU3ELz7XruGhp tCgjqsBNZFLJ0Qj3jtSW+8PrP/901MELXNThzcZ+U230KfgSP/mwMJsaae4nFhvNWWVy +qJRAKIjIko8rOVxhtuKktyrEBmUzdjhW49LE6/ASmUSge+PqCxVNJHJ9X07RpwekXiw RYEiICvIVYvUG0RuFPLZlwjcuiLrIH1B+ikWVnhMZa+lvXIM2uwtOWkTTOq0ixKgIZgs 1pvSnuKBcD9IU1W7uV/cFr013S6mHRQ54Dj0pNSRvWY7jaO8/FkCVXdFhnWtIVE+5s21 JbQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uY/6Z36Wpe8Rhmjf912uWmtdwXpqjAAYaeOTnRmS5HE=; b=Z8xaIhC7LXX8TOoz8ASNc0jc41Wa2wV/5mIB7t6A7bOmOzNnzWEOxDMssVBkrOGolp JHNkW19nWZs2TMAh8mU+77RmYl2ep8rmKRqi7w6f6Ba7nz3tY100OP0eei2XubmSZhpm nsZlhOLtbhmS4POKys6r5LucJqVwb4pEkVh9FvgaPy98d9HWAlLeAADdIaJEh2DFZ7k/ 2k7LViI8LNcIJljPf32VrAZ0eEPykRjbONuplSbognFAfiAnr7GwZ1T4B3oNYS5bhMIW Z6tAiH7QltwRfpBkOsQLmSMaZpIcuczQImvUgYLuyIEMJnht4OxU6/D/GJqdEC7Sj6EK zL5Q== X-Gm-Message-State: AGi0PuZTu+bim8BPibtNe2CEORQL0JzgRXYHUYpiwSVM7L01vDNV0t19 2OUa3Oe706boX53IV8VT3I9+60W5 X-Google-Smtp-Source: APiQypKuQFPZZbsPhIEOhgv01gpMOizYHppGoks6LpSN4MyhsdGCscNBeuzh0BH+nyFxUOnNG5e3Ag== X-Received: by 2002:a17:902:7d8a:: with SMTP id a10mr3835234plm.257.1587444543626; Mon, 20 Apr 2020 21:49:03 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id j7sm1054475pjy.9.2020.04.20.21.49.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2020 21:49:03 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Apr 2020 12:48:55 +0800 Message-Id: <20200421044855.15005-4-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200421044855.15005-1-lance.lmwang@gmail.com> References: <20200320151532.778-1-lance.lmwang@gmail.com> <20200421044855.15005-1-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v2 4/4] avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet 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: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang delete the previous change of ffmpeg.c and movenc.c as mux.c will be in charge of setting AV_PKT_FLAG_KEY. Signed-off-by: Limin Wang --- fftools/ffmpeg.c | 1 - libavformat/internal.h | 2 ++ libavformat/mux.c | 7 ++++++- libavformat/tests/movenc.c | 1 - 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 293561a8b1..d896b14a14 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1056,7 +1056,6 @@ static void do_subtitle_out(OutputFile *of, else pkt.pts += av_rescale_q(sub->end_display_time, (AVRational){ 1, 1000 }, ost->mux_timebase); } - pkt.flags |= AV_PKT_FLAG_KEY; pkt.dts = pkt.pts; output_packet(of, &pkt, ost, 0); } diff --git a/libavformat/internal.h b/libavformat/internal.h index 716e42cc3e..c4fac5cc76 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -189,6 +189,8 @@ struct AVStreamInternal { */ int need_context_update; + int is_intra_only; + FFFrac *priv_pts; }; diff --git a/libavformat/mux.c b/libavformat/mux.c index a6253f5430..ea6524f579 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -357,6 +357,8 @@ FF_ENABLE_DEPRECATION_WARNINGS if (desc && desc->props & AV_CODEC_PROP_REORDER) st->internal->reorder = 1; + st->internal->is_intra_only = ff_is_intra_only(par->codec_id); + if (of->codec_tag) { if ( par->codec_tag && par->codec_id == AV_CODEC_ID_RAWVIDEO @@ -773,6 +775,7 @@ static int check_packet(AVFormatContext *s, AVPacket *pkt) static int prepare_input_packet(AVFormatContext *s, AVPacket *pkt) { int ret; + AVStream *st = s->streams[pkt->stream_index]; ret = check_packet(s, pkt); if (ret < 0) @@ -781,7 +784,6 @@ static int prepare_input_packet(AVFormatContext *s, AVPacket *pkt) #if !FF_API_COMPUTE_PKT_FIELDS2 || !FF_API_LAVF_AVCTX /* sanitize the timestamps */ if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) { - AVStream *st = s->streams[pkt->stream_index]; /* when there is no reordering (so dts is equal to pts), but * only one of them is set, set the other as well */ @@ -818,6 +820,9 @@ static int prepare_input_packet(AVFormatContext *s, AVPacket *pkt) } } #endif + /* update flags */ + if (st->internal->is_intra_only) + pkt->flags |= AV_PKT_FLAG_KEY; return 0; } diff --git a/libavformat/tests/movenc.c b/libavformat/tests/movenc.c index 0ff87da7d6..1d15d97ad9 100644 --- a/libavformat/tests/movenc.c +++ b/libavformat/tests/movenc.c @@ -256,7 +256,6 @@ static void mux_frames(int n, int c) pkt.dts = pkt.pts = audio_dts; pkt.stream_index = 1; pkt.duration = audio_duration; - pkt.flags |= AV_PKT_FLAG_KEY; audio_dts += audio_duration; } else { if (frames == end_frames)