From patchwork Mon Apr 3 01:45:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 3254 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.44.195 with SMTP id s186csp2984685vss; Sun, 2 Apr 2017 18:46:53 -0700 (PDT) X-Received: by 10.223.172.55 with SMTP id v52mr14240199wrc.131.1491184013613; Sun, 02 Apr 2017 18:46:53 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i79si13131175wme.61.2017.04.02.18.46.53; Sun, 02 Apr 2017 18:46:53 -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; dkim=neutral (body hash did not verify) header.i=@gmail.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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 24622688357; Mon, 3 Apr 2017 04:46:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DB1BB680604 for ; Mon, 3 Apr 2017 04:46:12 +0300 (EEST) Received: by mail-qk0-f194.google.com with SMTP id r140so6331229qke.3 for ; Sun, 02 Apr 2017 18:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=I6T46TR4Js5WiI/Cuvng1uc3iD8YEsl62rl1pwOHzu4=; b=ERhnn+eGL0xgwtWevfv8CZmCzkNsO9hl7ESSdSfMji17K+xFUcdPcaMTPrHI6KwEv7 2QK8GXw5teQqXGqAZq/tVd6R37M0WSzRDCtGhoah+yCkfRi1nrzv3c1Xm4Yu9SI5yLRN NPC9KwF6DSQmtjNK9AtpYP9d3Pf8ZQBdc105Bum4x+gX9DbqNSGGFYVCx8L30a0zZzqx ONkkZEVN1Mg3t3FhZa1sNNXFkOiwNQMQq7ClhaedfJ7wX6OHaevbLSnYMZ6yoDCUsO4r 5wfNPEZrBwA0YiqKYJ4kIWY5TNXD2bBQYrlJ/U2Lp0LGT5uy8KaTTSku85ukRmhK2u0F Z7ag== 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:in-reply-to :references; bh=I6T46TR4Js5WiI/Cuvng1uc3iD8YEsl62rl1pwOHzu4=; b=ZN+lXNyCupbSXi1UTGfmpyw/cu6Rxd2JyPY45pLoOLBAGVkDc4j1YV+L4nw9dWuYE/ s3UT3RIZ2J4vgCym7DWmyVUEKZVR3vDisgC1e3xLndYy2sMG37eEJAF5IJ/HbaxW0fRY OSA2PNKOwJqDEkSNeOemn/X3eP2elmQmo65sHw8LE4V5FIQJpaTegTgveI+4krl65bjO FMAalonsV7MOqg/6hT87qhu2l5FVG6XMVfAWxc2G+4lXAXasCO0qod57rnR0whmqCrmt g6S+QUBjsIlNMUx7bXtkc2lh5Icp3KhJs2uIlC7jMh/0/y0JileWnUSdT3kD1W2pIbHc iGyQ== X-Gm-Message-State: AFeK/H30XeJaX/1nFCDevqPU4y26kreTU+mEAsrqWst/g0uhR9f/SqqzUstTnmMJLJHrAA== X-Received: by 10.55.191.6 with SMTP id p6mr13919698qkf.133.1491183973249; Sun, 02 Apr 2017 18:46:13 -0700 (PDT) Received: from localhost.localdomain ([181.231.62.139]) by smtp.gmail.com with ESMTPSA id n19sm8645200qtn.35.2017.04.02.18.46.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Apr 2017 18:46:12 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 2 Apr 2017 22:45:45 -0300 Message-Id: <20170403014545.3704-5-jamrial@gmail.com> X-Mailer: git-send-email 2.12.1 In-Reply-To: <20170403014545.3704-1-jamrial@gmail.com> References: <20170403014545.3704-1-jamrial@gmail.com> Subject: [FFmpeg-devel] [PATCH 5/5] avcodec/hevcdec: remove duplicate extradata parsing function 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" Use ff_hevc_decode_extradata() instead, which correctly only tries to decode parameter set NAL units and not any other NAL that may be present in extradata. Signed-off-by: James Almer --- libavcodec/hevcdec.c | 61 ++++++---------------------------------------------- libavcodec/hevcdec.h | 2 +- 2 files changed, 7 insertions(+), 56 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index ef21595c44..305aeda291 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -39,6 +39,7 @@ #include "golomb.h" #include "hevc.h" #include "hevc_data.h" +#include "hevc_parse.h" #include "hevcdec.h" #include "profiles.h" @@ -2976,63 +2977,13 @@ static int verify_md5(HEVCContext *s, AVFrame *frame) static int hevc_decode_extradata(HEVCContext *s, uint8_t *buf, int length) { - AVCodecContext *avctx = s->avctx; - GetByteContext gb; int ret, i; - bytestream2_init(&gb, buf, length); - - if (length > 3 && (buf[0] || buf[1] || buf[2] > 1)) { - /* It seems the extradata is encoded as hvcC format. - * Temporarily, we support configurationVersion==0 until 14496-15 3rd - * is finalized. When finalized, configurationVersion will be 1 and we - * can recognize hvcC by checking if avctx->extradata[0]==1 or not. */ - int i, j, num_arrays, nal_len_size; - - s->is_nalff = 1; - - bytestream2_skip(&gb, 21); - nal_len_size = (bytestream2_get_byte(&gb) & 3) + 1; - num_arrays = bytestream2_get_byte(&gb); - - /* nal units in the hvcC always have length coded with 2 bytes, - * so put a fake nal_length_size = 2 while parsing them */ - s->nal_length_size = 2; - - /* Decode nal units from hvcC. */ - for (i = 0; i < num_arrays; i++) { - int type = bytestream2_get_byte(&gb) & 0x3f; - int cnt = bytestream2_get_be16(&gb); - - for (j = 0; j < cnt; j++) { - // +2 for the nal size field - int nalsize = bytestream2_peek_be16(&gb) + 2; - if (bytestream2_get_bytes_left(&gb) < nalsize) { - av_log(s->avctx, AV_LOG_ERROR, - "Invalid NAL unit size in extradata.\n"); - return AVERROR_INVALIDDATA; - } - - ret = decode_nal_units(s, gb.buffer, nalsize); - if (ret < 0) { - av_log(avctx, AV_LOG_ERROR, - "Decoding nal unit %d %d from hvcC failed\n", - type, i); - return ret; - } - bytestream2_skip(&gb, nalsize); - } - } - - /* Now store right nal length size, that will be used to parse - * all other nals */ - s->nal_length_size = nal_len_size; - } else { - s->is_nalff = 0; - ret = decode_nal_units(s, buf, length); - if (ret < 0) - return ret; - } + ret = ff_hevc_decode_extradata(buf, length, &s->ps, &s->is_nalff, + &s->nal_length_size, s->avctx->err_recognition, + s->apply_defdispwin, s->avctx); + if (ret < 0) + return ret; /* export stream parameters from the first SPS */ for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) { diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index 0c7881286c..60f738f0b1 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -564,7 +564,7 @@ typedef struct HEVCContext { uint8_t is_md5; uint8_t context_initialized; - uint8_t is_nalff; ///< this flag is != 0 if bitstream is encapsulated + int is_nalff; ///< this flag is != 0 if bitstream is encapsulated ///< as a format defined in 14496-15 int apply_defdispwin;