From patchwork Mon Aug 19 01:41:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 14577 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 D5492448C7A for ; Mon, 19 Aug 2019 04:41:30 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AFD5568A62A; Mon, 19 Aug 2019 04:41:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A790268048C for ; Mon, 19 Aug 2019 04:41:23 +0300 (EEST) Received: by mail-pl1-f171.google.com with SMTP id 4so145360pld.10 for ; Sun, 18 Aug 2019 18:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=VpQUofc7FyKzabt7kDCGNVXc3V1Nf0Qo0aeuXvbLSFU=; b=r0a4PiW7IdGtMvcIU3200v/puaOTCM1BwPVmnWFVcJKoozNfjMdulz5rr9pEMADDY9 FnO12nm7wAZ3t33diqzAEg5mqnEJ8zn6IYimyX+dCeRWjWgPw1GciWwP2eDvcL+YVJt1 0zQ3d/S1Jh+nCl3Kp7VLcu/avfzZoTWfWJ7v1ZOO9f6sJbRMLa8h65vmMNxzzJOkAY7s LfiNISgrhKg0oWLprAFMFe/GgGGh2uB//BEWcr53N9e0clzLO3jHPVb5rGgpdrjO4N0i 7/W09UIf9COiQX5Vc/rwDOxOH1apZ9KYIu68eXq+SHVMxgMCJrr/FU6NOTogIafi7Zjf mt0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=VpQUofc7FyKzabt7kDCGNVXc3V1Nf0Qo0aeuXvbLSFU=; b=LUIB5GEwaKZ5Qe0jMfkUs5+gMVgJx2J1XF9s1lk/EIN+aqPfJ2InY9vIsPa5/WOGDj X8h9XxxxUiDM7R1ksc9I0VlDpOk+FC+1BsOhCVk/lk4/LHKC0hwf+ArWtQrEalAMbnGQ Jci0XMi5jOvgTP+M2boxduJarwyi+z3qDyDv+tiVPdwbxPNWq9HtyZn9G+SK9sK5zNzd O7WeDKhU79v1L2vVb48/MWcwsGql4IJI3xVIszZD+9NDPDswJvowg1DlPdhPwha2+0Q/ MIZoG2+BwivStCWC4tP+tGzGZ2+PTbw6xTjgQl1ntjz655u39kXx2kFzN3P5egpBJ2Ru ioNw== X-Gm-Message-State: APjAAAU2yZF8K4au/JK3RZCOkdrfyKqn+pDsfNxiYhOe5cATsMfwQ4p3 fHjFqmOyjniKTgpFwplKp9fjMKys X-Google-Smtp-Source: APXvYqyFZp1aq/qvZ9kKNIPirwj4rbb0UOM/DPazTT3w1DyPxR3fvTqP0hAk+DBcPakyx84kFPWhlQ== X-Received: by 2002:a17:902:b08a:: with SMTP id p10mr20507596plr.83.1566178881492; Sun, 18 Aug 2019 18:41:21 -0700 (PDT) Received: from jun-ubuntu.corp.microsoft.com ([2001:4898:80e8:f:c383:b76b:4a7:2be3]) by smtp.googlemail.com with ESMTPSA id 4sm13630662pfn.118.2019.08.18.18.41.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 18:41:20 -0700 (PDT) From: Jun Li To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Aug 2019 18:41:14 -0700 Message-Id: <20190819014114.4336-1-junli1026@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH v1] avcodec/h264_parse: retry decoding SPS with complete NAL 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fix #6591 The content has no rbsp_stop_one_bit for ending the SPS, that causes the decoding SPS failure, results decoding frame failure as well. The patch is just adding a retry with complete NALU. --- libavcodec/h264_parse.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c index ac31f54e07..a2267a0610 100644 --- a/libavcodec/h264_parse.c +++ b/libavcodec/h264_parse.c @@ -376,8 +376,14 @@ static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps, switch (nal->type) { case H264_NAL_SPS: ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps, 0); - if (ret < 0) - goto fail; + if (ret < 0) { + GetBitContext tmp_gb = nal->gb; + av_log(logctx, AV_LOG_DEBUG, + "SPS decoding failure (maybe missing rbsp_stop_one_bit), trying again with the complete NAL\n"); + init_get_bits8(&tmp_gb, nal->raw_data + 1, nal->raw_size - 1); + if ((ret = ff_h264_decode_seq_parameter_set(&tmp_gb, logctx, ps, 0)) < 0) + goto fail; + } break; case H264_NAL_PPS: ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps,