From patchwork Tue Jul 26 12:41:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 5 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.67 with SMTP id o64csp1274277vsd; Tue, 26 Jul 2016 05:42:07 -0700 (PDT) X-Received: by 10.194.143.17 with SMTP id sa17mr19353504wjb.97.1469536927011; Tue, 26 Jul 2016 05:42:07 -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 p71si28785318wmb.47.2016.07.26.05.42.06; Tue, 26 Jul 2016 05:42:06 -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=@martin-st.20150623.gappssmtp.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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 298B668A432; Tue, 26 Jul 2016 15:42:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 560E368A42B for ; Tue, 26 Jul 2016 15:41:54 +0300 (EEST) Received: by mail-wm0-f66.google.com with SMTP id q128so1489325wma.1 for ; Tue, 26 Jul 2016 05:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=z2wy4QwgsL6J8Zzfh5dSVoY1FP4HELBKmnKQ8alV4FU=; b=QqQ6dzYEVnx0pxxu1qaGFCeB8z2iil4jFA+QPeKYNacwYHffusA5jTLfCDFTZ8OYP8 UGSmHxeiFJXPzAyqNsp+HR6BVDJYgTNTowxcYktFW/QqNRTd+cc3bpDLiQxco/xLlzBr my+3b4IBmSL9UHmhkWjF3tYFS2UPR8pe6RFNS5KSbYc6W3O4lXIglrFrJFS0O/NJRdBT TYlD9SAj5fzfJY1r85XCaxcJ5xUR7Mxd1g212gmbdBepV72HfZoIpKbVYDlKLQkAKSy9 gaIWysO/TubWhC5vYVf86Ihvk2B2/lmC2OoaMGluB/TzzguxtilHWflJCsHTuOytiMNI l/kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=z2wy4QwgsL6J8Zzfh5dSVoY1FP4HELBKmnKQ8alV4FU=; b=gldr4FoxiW7YBk5eLjyAlp8bJpkxc6dWGoTAAYX4X67ZKoF1NsBrFEawlUrrAQL23C uaWEm/Ya+0w9tICWyYuIGHgRHbswIxPLpdpyrpgn2DM+2GdKxRQ5QV3kderaCi01F7gP /Du61MZGKtz4b52/2sZRWqFNHpjAGdZQwQkt5INX/CKLAWnS/y82iC7yY/2lbWXYXLmg FVHbs16UFgrD4Ny7dwQGkNWTSWPCoRKQNIkruq86Abk9QyEdVyY2Y4X7VrVAdgHzoTtC qIcToLRdrubEwtho/8stWJ3DbdKCFpqlgrtDNSvMQykjnt4YxebRymge+zs0MTnV4MT3 NpVA== X-Gm-Message-State: ALyK8tJArjt5Mly7+sNWvvuAJ/VGUPUanBDSrmfoPe6wAxyY/btPr9zcsswqj1G+LEMxmQ== X-Received: by 10.28.18.149 with SMTP id 143mr46484029wms.28.1469536917459; Tue, 26 Jul 2016 05:41:57 -0700 (PDT) Received: from localhost ([2001:470:28:852:60fd:8228:b11e:afad]) by smtp.gmail.com with ESMTPSA id a194sm32696836wmd.24.2016.07.26.05.41.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 26 Jul 2016 05:41:57 -0700 (PDT) From: =?UTF-8?q?Martin=20Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Tue, 26 Jul 2016 15:41:53 +0300 Message-Id: <1469536913-48931-2-git-send-email-martin@martin.st> X-Mailer: git-send-email 2.7.4 (Apple Git-66) In-Reply-To: <1469536913-48931-1-git-send-email-martin@martin.st> References: <1469536913-48931-1-git-send-email-martin@martin.st> Subject: [FFmpeg-devel] [PATCH 2/2] libopenh264: Support building with the 1.6 release 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" This is cherry-picked from libav commit d825b1a5306576dcd0553b7d0d24a3a46ad92864. --- libavcodec/libopenh264dec.c | 2 ++ libavcodec/libopenh264enc.c | 26 ++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/libavcodec/libopenh264dec.c b/libavcodec/libopenh264dec.c index 8388e4e..80dff4c 100644 --- a/libavcodec/libopenh264dec.c +++ b/libavcodec/libopenh264dec.c @@ -90,7 +90,9 @@ static av_cold int svc_decode_init(AVCodecContext *avctx) (*s->decoder)->SetOption(s->decoder, DECODER_OPTION_TRACE_CALLBACK, (void *)&callback_function); (*s->decoder)->SetOption(s->decoder, DECODER_OPTION_TRACE_CALLBACK_CONTEXT, (void *)&avctx); +#if !OPENH264_VER_AT_LEAST(1, 6) param.eOutputColorFormat = videoFormatI420; +#endif param.eEcActiveIdc = ERROR_CON_DISABLE; param.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT; diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index d27fc41..07af31d 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -33,6 +33,10 @@ #include "internal.h" #include "libopenh264.h" +#if !OPENH264_VER_AT_LEAST(1, 6) +#define SM_SIZELIMITED_SLICE SM_DYN_SLICE +#endif + typedef struct SVCContext { const AVClass *av_class; ISVCEncoder *encoder; @@ -48,11 +52,20 @@ typedef struct SVCContext { #define OFFSET(x) offsetof(SVCContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { +#if OPENH264_VER_AT_LEAST(1, 6) + { "slice_mode", "set slice mode", OFFSET(slice_mode), AV_OPT_TYPE_INT, { .i64 = SM_FIXEDSLCNUM_SLICE }, SM_SINGLE_SLICE, SM_RESERVED, VE, "slice_mode" }, +#else { "slice_mode", "set slice mode", OFFSET(slice_mode), AV_OPT_TYPE_INT, { .i64 = SM_AUTO_SLICE }, SM_SINGLE_SLICE, SM_RESERVED, VE, "slice_mode" }, +#endif { "fixed", "a fixed number of slices", 0, AV_OPT_TYPE_CONST, { .i64 = SM_FIXEDSLCNUM_SLICE }, 0, 0, VE, "slice_mode" }, +#if OPENH264_VER_AT_LEAST(1, 6) + { "dyn", "Size limited (compatibility name)", 0, AV_OPT_TYPE_CONST, { .i64 = SM_SIZELIMITED_SLICE }, 0, 0, VE, "slice_mode" }, + { "sizelimited", "Size limited", 0, AV_OPT_TYPE_CONST, { .i64 = SM_SIZELIMITED_SLICE }, 0, 0, VE, "slice_mode" }, +#else { "rowmb", "one slice per row of macroblocks", 0, AV_OPT_TYPE_CONST, { .i64 = SM_ROWMB_SLICE }, 0, 0, VE, "slice_mode" }, { "auto", "automatic number of slices according to number of threads", 0, AV_OPT_TYPE_CONST, { .i64 = SM_AUTO_SLICE }, 0, 0, VE, "slice_mode" }, { "dyn", "Dynamic slicing", 0, AV_OPT_TYPE_CONST, { .i64 = SM_DYN_SLICE }, 0, 0, VE, "slice_mode" }, +#endif { "loopfilter", "enable loop filter", OFFSET(loopfilter), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE }, { "profile", "set profile restrictions", OFFSET(profile), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE }, { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, @@ -159,15 +172,24 @@ FF_ENABLE_DEPRECATION_WARNINGS s->slice_mode = SM_FIXEDSLCNUM_SLICE; if (s->max_nal_size) - s->slice_mode = SM_DYN_SLICE; + s->slice_mode = SM_SIZELIMITED_SLICE; +#if OPENH264_VER_AT_LEAST(1, 6) + param.sSpatialLayers[0].sSliceArgument.uiSliceMode = s->slice_mode; + param.sSpatialLayers[0].sSliceArgument.uiSliceNum = avctx->slices; +#else param.sSpatialLayers[0].sSliceCfg.uiSliceMode = s->slice_mode; param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceNum = avctx->slices; +#endif - if (s->slice_mode == SM_DYN_SLICE) { + if (s->slice_mode == SM_SIZELIMITED_SLICE) { if (s->max_nal_size){ param.uiMaxNalSize = s->max_nal_size; +#if OPENH264_VER_AT_LEAST(1, 6) + param.sSpatialLayers[0].sSliceArgument.uiSliceSizeConstraint = s->max_nal_size; +#else param.sSpatialLayers[0].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = s->max_nal_size; +#endif } else { av_log(avctx, AV_LOG_ERROR, "Invalid -max_nal_size, " "specify a valid max_nal_size to use -slice_mode dyn\n");