From patchwork Wed Aug 15 06:37:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 9997 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:104:0:0:0:0:0 with SMTP id c4-v6csp453648jad; Tue, 14 Aug 2018 23:38:10 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy2gYEi3hf/2xO4SBbhGDR2mSXrfd4a/2RojHVw8k70jjO75QNJWIY6zGhwGStf1n7IQ1dq X-Received: by 2002:a5d:4b90:: with SMTP id b16-v6mr4857029wrt.168.1534315090450; Tue, 14 Aug 2018 23:38:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534315090; cv=none; d=google.com; s=arc-20160816; b=b9q9DOj/5nbeO9/STFlz+lTvHVThEanDNzFL9Y8mWU6+/reih/yC23CJvCBKLOwpPo nhuZtMM5OJyw95PTBr8GoXBg1aLPLdQZ6aTJuCN5Gr86o9sqbEJ3443l8zcJ10D3e+8x HfbiiObX0THe2Nx/tF9iWLfLbHaa83eO2+fGt4eXpmmUFXV41AJVn3xrJ4AjCjNdTLm9 8m1eZ7jhd7oYONM7Z/AR06/hG9GzNW12nA5NtRPVHEp1FfWB2Upzyuh113R5jPuO+yzT SfFDrIAKxe3tbWMVhHcpytUsPG92sc/TbtnI9CJ2GiciiMkvIOFCm/4h7WTDe5aSy7FZ tv1w== 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:message-id:date:to:from:delivered-to :arc-authentication-results; bh=PQ2ePYkG3V7r0hSFysuSCdTxXppM+sLvl1nSrKSDNYA=; b=iz7qOd0IKIITnCAtIiHeH9dryd5l/nCpVsRCoCmfBOTGSMOvS6Ar1/w8tP4dYM5cU5 OPgFXzzZJG9Ka5neVPXh3uN2GZuAAH8CwWtp6yQJBzt+ez+ayTS3FSe9Rhfp6QGV6pnS mqYlPl+rmOgVy4tIcVekuoI9lFSQRmBpXWWWg3rspuRPff+80kaKQDDY9UvvIPHwj0+v I1fG0ERlvfSH5+Ca4FP4QGNFpIW9TQ1stBNzROt8WTHX5lDyk2gsD6uEDlVKqbM+cKZ9 VWskBbZW3AOTCtKq4g+zqLjs5x/IiCvh0X81EhDryI8RforkJdsWPVdxC7nNkB0SWnCo owTA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id e6-v6si14841783wrr.152.2018.08.14.23.38.09; Tue, 14 Aug 2018 23:38:10 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8923968A628; Wed, 15 Aug 2018 09:37:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 63D1068A3F6 for ; Wed, 15 Aug 2018 09:37:36 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Aug 2018 23:37:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,241,1531810800"; d="scan'208";a="81881670" Received: from ideapad.sh.intel.com ([10.239.160.152]) by orsmga001.jf.intel.com with ESMTP; 14 Aug 2018 23:37:39 -0700 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Aug 2018 14:37:38 +0800 Message-Id: <20180815063738.27192-1-linjie.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] avcodec/h264_mp4toannexb_bsf: add No IDR frame situation 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: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fix the live stream encoding problem using qsv when the first frame is not an IDR frame. Add the extradata information when the IDR frame is missing in the first GOP. Fixes the bug reported in ticket #6418. Signed-off-by: Linjie Fu --- libavcodec/h264_mp4toannexb_bsf.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index 794c82e650..fbbfe3f7dd 100644 --- a/libavcodec/h264_mp4toannexb_bsf.c +++ b/libavcodec/h264_mp4toannexb_bsf.c @@ -33,6 +33,7 @@ typedef struct H264BSFContext { int32_t pps_offset; uint8_t length_size; uint8_t new_idr; + uint8_t new_nal_slice; uint8_t idr_sps_seen; uint8_t idr_pps_seen; int extradata_parsed; @@ -243,6 +244,7 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) buf, nal_size, 1)) < 0) goto fail; s->new_idr = 0; + s->new_nal_slice = 1; /* if only SPS has been seen, also insert PPS */ } else if (s->new_idr && unit_type == H264_NAL_IDR_SLICE && s->idr_sps_seen && !s->idr_pps_seen) { if (s->pps_offset == -1) { @@ -253,7 +255,16 @@ static int h264_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out) ctx->par_out->extradata + s->pps_offset, ctx->par_out->extradata_size - s->pps_offset, buf, nal_size, 1)) < 0) goto fail; - } else { + }else if (s->new_idr && !s->new_nal_slice && H264_NAL_SLICE == unit_type && !s->idr_sps_seen && !s->idr_pps_seen) + { + av_log(ctx, AV_LOG_WARNING, "first H264_NAL_SLICE when there is no IDR.\n"); + if ((ret = alloc_and_copy(out, ctx->par_out->extradata, ctx->par_out->extradata_size, buf, nal_size, 1)) < 0) + goto fail; + s->new_nal_slice = 1; + s->new_idr = 0; + } + + else { if ((ret=alloc_and_copy(out, NULL, 0, buf, nal_size, unit_type == H264_NAL_SPS || unit_type == H264_NAL_PPS)) < 0) goto fail; if (!s->new_idr && unit_type == H264_NAL_SLICE) {