From patchwork Thu Aug 23 08:17:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 10101 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp1827967jap; Thu, 23 Aug 2018 01:20:04 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda6bucU31ZTH4Lf7Kb07reO8HWy3fam/heNDJ+yO+G1JunE+E5gT5dDZ3E8d/bfn0LBfXWj X-Received: by 2002:a1c:b50e:: with SMTP id e14-v6mr1628181wmf.117.1535012404706; Thu, 23 Aug 2018 01:20:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535012404; cv=none; d=google.com; s=arc-20160816; b=sJtclAmlVYKTh84YZUBSzrjr9T0wYDEp6oiNkUG8kEOyGbS9pONfjKMOUESwYfiP4b hM0CX6HR/VwuxsXze2SyR3/oS3pLJjGgaHKZtqzgvN7kTul4vTlvosi2wsfxsPyTIbR5 fK9GSTaOzK3vkhoKHNpl6fUYRGbe+cpPiMZZ7Li3/jMRVCFB46K7Oa+Yt2Cw8PUsalj0 gqdBjK8fvuoOvbd8mo9ArSODDgu+NvXNQYJE2UwvMOLWrDERCoiL2AlzDaZN8pr1PdpT 0tEJjDpT7gRWfL1YNHN5T9tkRo81DNKfUhziSEfKRVlxX1PN8SKH05vrqTUfPiI8BcHa dGxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:dlp-reaction:dlp-version :dlp-product:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:to:from:delivered-to :arc-authentication-results; bh=DtJpWZE5Hp/HiraZQbJNwl/fbhDtTZb+LhHLwerY7JE=; b=aGFQ0OD1+4BL5gKyrR9PG3O7G+tZXQMC2vWK2Ji9Ip53DfmqCYhzAQQcm5bSfmCeHm 9BP/JtUrFXzFNm3oUHRrLsHsywoYPyD+Y/Uwx4gIxUfAPN9Q8tBp13ClgRkIrvL2QDB1 itkb/4pwmEZ9xaVYguDPEzvmZc/xVLriXqlPbggcPhl8zNnNz7mEh5bRfc5j4pLvyY9w PO6L62B9Ie4d2PX2dSuzSYGXAm4mleN9cqUZQBMz9QXRwSGUZ79pwxN+SOu62PAJBstz Xdgyopf3fcQmjSf4TQPWjC22ps9yCcRicHOqqfW13HYnJ/1/bGwDfzekc3MkdCUGLKgW MKGA== 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 m11-v6si3146098wri.185.2018.08.23.01.20.03; Thu, 23 Aug 2018 01:20: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; 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 2F7F6689BAE; Thu, 23 Aug 2018 11:20:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 585E168824F for ; Thu, 23 Aug 2018 11:19:53 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Aug 2018 01:19:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,277,1531810800"; d="scan'208";a="251257853" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga005.jf.intel.com with ESMTP; 23 Aug 2018 01:17:23 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 23 Aug 2018 01:17:23 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 23 Aug 2018 01:17:22 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.226]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.185]) with mapi id 14.03.0319.002; Thu, 23 Aug 2018 16:17:20 +0800 From: "Fu, Linjie" To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH V2] avcodec/h264_mp4toannexb_bsf: add No IDR frame situation Thread-Index: AQHUNS/k3xES369aOkm4q5DB+aX1MKTNCKiQ Date: Thu, 23 Aug 2018 08:17:19 +0000 Message-ID: References: <20180816070750.29150-1-linjie.fu@intel.com> In-Reply-To: <20180816070750.29150-1-linjie.fu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTliYTZjZGEtNWZlOC00N2IzLTlkZWEtYTMzYmNiM2M1MmI5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiUktFWXRHaktNYWd1YitWQ0JhektJTTExWldGMjRoaFwvcHJIdGxTWWFER1gzem1jY2FRdjd0QUt4d3R2c3lJVVwvIn0= x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH V2] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" -----Original Message----- From: Fu, Linjie Sent: Thursday, August 16, 2018 15:08 To: ffmpeg-devel@ffmpeg.org Cc: Fu, Linjie Subject: [PATCH V2] avcodec/h264_mp4toannexb_bsf: add No IDR frame situation 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. Fix the bug reported in ticket #6418. [PATCH V2] Fix the coding style. Signed-off-by: Linjie Fu --- libavcodec/h264_mp4toannexb_bsf.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.17.1 Ping. diff --git a/libavcodec/h264_mp4toannexb_bsf.c b/libavcodec/h264_mp4toannexb_bsf.c index 794c82e650..fbb9f1fe20 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,6 +255,12 @@ 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 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;