From patchwork Tue Aug 20 02:24:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 14604 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 81363449A96 for ; Tue, 20 Aug 2019 05:24:55 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 50A9A68A97D; Tue, 20 Aug 2019 05:24:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 52B6568A1CC for ; Tue, 20 Aug 2019 05:24:49 +0300 (EEST) Received: by mail-pl1-f172.google.com with SMTP id y8so1903365plr.12 for ; Mon, 19 Aug 2019 19:24:49 -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=Ro7yv8dJ6cJ3WgiV+N08wrAIEiakRyaTADuGLgrolMo=; b=TCgdJl28YMFV3OY77VsPuXnAwdXe1EVN594VlNJiG+lgGJoAxsRMrHG2z/5qksZZvw 2aaMfksyEDLyKpAjen6saNnQBe+wfxrjbGD1ukIQn32uXz0BGcGzd9mNOczZrl0Y1Fr4 4IBs3fy5/Muw4yDkqSqMWQqGPCDOmLLS63/r4y1v04wRRwQneboFficbsXEgnI8xgfJU CbnJPMbhkIliVHoNBWo8fidJdYz0wvSDhmwTJ3LHLXLDCGK9Tn7HsQ9091beyopzDDcB iMkwixrerywTxdijmnjuU+jv9e2BHibyfrRCu1HKAUcXWm75CJoRojmZstKJGxzCUshT SbLw== 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=Ro7yv8dJ6cJ3WgiV+N08wrAIEiakRyaTADuGLgrolMo=; b=hZkuJHQzuueaY8sk9o0auPeNgUp9Ec9dMLUfjBM+NvGEgi1UONLMMT9xzoG58c7vbn UrCY3tBz7ov60DzH+x2sHd8rYM5pmKgjPfNfIiTmBn+vrUEV44CL/aO2ts+jWHE4KUqc YO5bFHJM9xWiJJyWXXOMVSKB+7Qbp0ePVleZsFBt4BeKx1HvlPB0czNJMm6ZJnxPrNwN EKo6QG01t4gErTqSg/tOXVfSP6Z+ymoqIq7eke96Mcb9bXsSck+fgHuPr14++QrO34nL lyXtUol6YdbK9SeRoPl6DXQ5IgX7YM0MoYxrPDSuGytd7WaCpn1W+N8BT4xxpcGEjOPj yDIA== X-Gm-Message-State: APjAAAV1acplsyQn2UIcY8KUyem8BFxNN3PuaR+t4uz+DW7GxPZP7yha MAQGaZJmji8XSbFq+kykD0jRQJmz X-Google-Smtp-Source: APXvYqwlbX6sO5qSDZNfMiDg0wzmfKH4IgYM1JPVe2pYgPTAOM7cklUdbn5WYYMYVHneyNo7xbnBEQ== X-Received: by 2002:a17:902:6b88:: with SMTP id p8mr24867972plk.95.1566267887113; Mon, 19 Aug 2019 19:24:47 -0700 (PDT) Received: from jun-ubuntu.corp.microsoft.com ([2001:4898:80e8:b:a411:9cc:22e4:8e9c]) by smtp.googlemail.com with ESMTPSA id p3sm13585900pjo.3.2019.08.19.19.24.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 19:24:46 -0700 (PDT) From: Jun Li To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Aug 2019 19:24:36 -0700 Message-Id: <20190820022436.6773-1-junli1026@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH v2] 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, copied from the retry in decode_nal_unit() --- libavcodec/h264_parse.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c index ac31f54e07..ea7a958dd9 100644 --- a/libavcodec/h264_parse.c +++ b/libavcodec/h264_parse.c @@ -376,8 +376,15 @@ 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, 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 && + (ret = ff_h264_decode_seq_parameter_set(&tmp_gb, logctx, ps, 1)) < 0) + goto fail; + } break; case H264_NAL_PPS: ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps,