From patchwork Sat Jan 20 04:12:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 7355 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.156.27 with SMTP id q27csp313973jak; Fri, 19 Jan 2018 20:13:31 -0800 (PST) X-Google-Smtp-Source: AH8x226hHL90fLjV07gI1GbWeVUj/VTP58wJAytZ9GQWA6GCOg/Jmxu10bhdHNE1TAE79vq+bs9W X-Received: by 10.223.136.110 with SMTP id e43mr484493wre.98.1516421610989; Fri, 19 Jan 2018 20:13:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516421610; cv=none; d=google.com; s=arc-20160816; b=Ts5F6+NIyksur+AIY6ceoLcDJPyxSrOPw21D4mhKvRLW/E4Zl3A7tuPd6Q32L/U0X/ /M25Bclmm2v+0+6veCmP55u/n0kXA1pAsrV8AFcTxdWlWPZhvSwLnq0MsyPr+tEwXCLL GHoXkS3VpIpocKePqnUErrl9u+H3TOThoYbnHXtpqEUUCcb1YBg/vZfLISZVWkit82in Tw1g/d2kBjt5xwGTsUuYhLQj5hKT5WhV7RXR1TDWojxQNaq5IJeWlgsHduB4vooGM+Id cg/z3qWa/Hrk8nnflPC+8GVT5YgXop/6/7N+x9uQFIi+K9BNklq2sLyzxcwu7XdBKqyl bknw== 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:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=UOg4tyMUt5y+mwNOFk4xBJ7J69pY2rHpWzsTE/EmnTo=; b=GMLRaLN+GJYWQdqsULYaQ0AASYcuYxnFrPeRdBY9xaawDVWgsoMNC5O01oo3wRjxTd 1Ex9sBEF8T+A9gDLRqKSQVlb871Hv8rIczX5Z2k/+CBRt4l/wzEKhA82Bw6HafRwnr6x 1WFF9d+oknPHbKeY3wo3k1pzmUvx4ck71t6nAdmTl/fIUJyamwy9gB08VQDtzJkXtTx9 wS2JV0w2bihNgxCs+Sdee9z6Rpc116y1G+aE3CRQ2xstaGv+Ew+dTzYZkRlcIdE/OZKX FuY/xgu5dJJZOxb3x50oa2epkDuDxNzCjQlS7rt2KTxpPVgJt3QqWbbBZCRvO58xkunH fA6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=ci6Icojh; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i67si1813704wmi.164.2018.01.19.20.13.30; Fri, 19 Jan 2018 20:13:30 -0800 (PST) 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 header.s=20161025 header.b=ci6Icojh; 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 E7115689A77; Sat, 20 Jan 2018 06:13:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f195.google.com (mail-qt0-f195.google.com [209.85.216.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C8AB7680B0E for ; Sat, 20 Jan 2018 06:13:21 +0200 (EET) Received: by mail-qt0-f195.google.com with SMTP id d8so206512qtm.0 for ; Fri, 19 Jan 2018 20:13:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=s4jNVsdA4av9kySk940lPd5PBoK+lfjS2WAgPbQmARQ=; b=ci6IcojhaFkhNyFxfljRRjQOPc0wQPgYuRa6Pl96yG+9EcUrDxUkY3V1TGIDh7fgQU zZG/W/GX6XL7O8/ZUGZNed74QXjDw9sBU7DCXP2D3+kvzXQV6lwkZoQ4bBKXyioffkNd jIdnB7bwh+BhrfQoYvQAl4Oloj3j22n10XzjDhVFaLWP3BN+xDLLeDWQUQj7gCvTg9F5 OM7DDfHTlXGlgwzhS+1om4GDJH1CDM255u769Gcrhox3MDwK0QMKb6OXP1j0ItO9dFLg dSliVXYwpsW6M3fuyoRas4kluLbSEy+vpTfWbF9PPsYp3qwfKlI+qALxXLpDXBObyzLb 7Mwg== 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=s4jNVsdA4av9kySk940lPd5PBoK+lfjS2WAgPbQmARQ=; b=Zb6dTRrA49qg2VSfSyxrnabpPB6Swyu2aLopKMV0oeRB1BjTKaoxw0xQ4Ib0mHd3Zn fuyy+G5HFu2CEtpglrpLqP4eW7pQLimgHNMbEfWpoeym9iz4115D0+pd1doHdarlq+Av MY8KD+v0GnQoNqoZICYT9tq9AwHQo8PMWmcuVlh/mSP9u0/0hNLIqD6RVsyllc3GR/WJ g5RzwTKu95HkgsfgM2LpIflsG0/x+xz+6y8II+QPPOi8iMqWFbgPWpSrKBy0L5pbPxU0 OCVwZINAqq2qL1KiFljtGZJr5ZGwETYj7THJF9Jp9jrOzJjzA25g6IRsSlwphuMz9kJ+ EtxQ== X-Gm-Message-State: AKwxytfs0NAIyVuc9fz3XS+mc4azdvwCWxO9wnT34Ca2iI8xtdLGme6P JGaUcTcI0/1WJ4nirm4IYhSRsQ== X-Received: by 10.200.54.138 with SMTP id a10mr1003284qtc.123.1516421601112; Fri, 19 Jan 2018 20:13:21 -0800 (PST) Received: from localhost.localdomain ([181.229.225.176]) by smtp.gmail.com with ESMTPSA id d26sm7730009qtk.54.2018.01.19.20.13.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Jan 2018 20:13:20 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 20 Jan 2018 01:12:49 -0300 Message-Id: <20180120041249.5692-1-jamrial@gmail.com> X-Mailer: git-send-email 2.15.0 Subject: [FFmpeg-devel] [PATCH] avcodec/hevc_parser: use ff_hevc_decode_extradata() to parse extradata 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" Signed-off-by: James Almer --- libavcodec/hevc_parser.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c index ff7e8a49d6..a3a9098c7c 100644 --- a/libavcodec/hevc_parser.c +++ b/libavcodec/hevc_parser.c @@ -24,6 +24,7 @@ #include "golomb.h" #include "hevc.h" +#include "hevc_parse.h" #include "hevc_ps.h" #include "hevc_sei.h" #include "h2645_parse.h" @@ -43,6 +44,8 @@ typedef struct HEVCParserContext { HEVCSEI sei; SliceHeader sh; + int is_avc; + int nal_length_size; int parsed_extradata; int poc; @@ -181,7 +184,6 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, HEVCParserContext *ctx = s->priv_data; HEVCParamSets *ps = &ctx->ps; HEVCSEI *sei = &ctx->sei; - int is_global = buf == avctx->extradata; int ret, i; /* set some sane default values */ @@ -191,8 +193,8 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, ff_hevc_reset_sei(sei); - ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, 0, 0, - AV_CODEC_ID_HEVC, 1); + ret = ff_h2645_packet_split(&ctx->pkt, buf, buf_size, avctx, ctx->is_avc, + ctx->nal_length_size, AV_CODEC_ID_HEVC, 1); if (ret < 0) return ret; @@ -230,12 +232,6 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, case HEVC_NAL_RADL_R: case HEVC_NAL_RASL_N: case HEVC_NAL_RASL_R: - - if (is_global) { - av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", nal->type); - return AVERROR_INVALIDDATA; - } - ret = hevc_parse_slice_header(s, nal, avctx); if (ret) return ret; @@ -243,8 +239,7 @@ static int parse_nal_units(AVCodecParserContext *s, const uint8_t *buf, } } /* didn't find a picture! */ - if (!is_global) - av_log(avctx, AV_LOG_ERROR, "missing picture in access unit\n"); + av_log(avctx, AV_LOG_ERROR, "missing picture in access unit\n"); return -1; } @@ -301,7 +296,9 @@ static int hevc_parse(AVCodecParserContext *s, AVCodecContext *avctx, ParseContext *pc = &ctx->pc; if (avctx->extradata && !ctx->parsed_extradata) { - parse_nal_units(s, avctx->extradata, avctx->extradata_size, avctx); + ff_hevc_decode_extradata(buf, buf_size, &ctx->ps, &ctx->sei, &ctx->is_avc, + &ctx->nal_length_size, avctx->err_recognition, + 1, avctx); ctx->parsed_extradata = 1; }