From patchwork Sat Mar 3 00:13:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Bouron X-Patchwork-Id: 7804 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.181.170 with SMTP id m39csp103566jaj; Fri, 2 Mar 2018 16:19:10 -0800 (PST) X-Google-Smtp-Source: AG47ELsff4YiqbScktgC8gQyaSabESYhRttSb7KBG5AWHNQTkfIub8etN1n9W1x1r1EcoAbbaYjV X-Received: by 10.28.3.4 with SMTP id 4mr2946199wmd.60.1520036350268; Fri, 02 Mar 2018 16:19:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520036350; cv=none; d=google.com; s=arc-20160816; b=LzMSFFDP7z0ZD1A3oBM4XYbkbtMklkyrDArUgtfmEr/9NHhxPSqE5g3QORYFVmHPWT uRVoeEiOubCEpm2ad+GGhwAjtN026bhQ0D+ULhicbecmCwha4y7nt7/t2CmxXcZW6/51 ljbd26WWT2V5qB5vHAtW7EL5O4wDsl8Rdi/ZGkScDJLEvad3qk5sD9AwsjLgCmiHfaz6 rzKuD4uvzHHQ7iYGrHfjNnJly9igjTsXe9o8dTqil2Utbr/G5zhoxF3Xd7Bso11Mffzs 6ACZrAhpGh4NCH9VeK2e+YfiHy5JO62NIffrpQZC3i3e9ObtjDc9a1I52eR7yVYo4GR2 +MBw== 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:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=BXdxuVwLBFC6YpTRJK7sFvU4S6F0PekkFM6cY6XmtAI=; b=CMMP8yrjX+xJ18HOR4YW4eD+Wu7H+ulqDW6kcJ0yGviQVHjYQXowIv8xEZwYXW/2uY rEX7Kt+UDS12/uZP9U5LYI8rI+gIBUiS35AtzRwS6VP+nIn8YUd4hSn2Z4Lnl105H97u X/2AhJY5q/JXy1mW8Ojt6cGwXbfxSAF5TyggWMLXKGntVN+slb01dTlvJEF4Po96QVbo Gkr56ElZpYeOgXYA6UqAMzhQpZCprd4PXJic+hCaPi1E3TRW3bxA8MboO9UENL/ENGOz ciE0oRZFj0VJrgB0zPQ+i+Ekvxt12MUbeRP+h/OAhxd7NutqBR0xB6tjaBYmVpYuWa9x CkYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Y8e6XCGK; 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=QUARANTINE 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 k23si5359863wrc.70.2018.03.02.16.19.09; Fri, 02 Mar 2018 16:19:10 -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=Y8e6XCGK; 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=QUARANTINE 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 1BC5C68A726; Sat, 3 Mar 2018 02:18:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BB68F68A6F7 for ; Sat, 3 Mar 2018 02:18:57 +0200 (EET) Received: by mail-wm0-f68.google.com with SMTP id s206so5080616wme.0 for ; Fri, 02 Mar 2018 16:19:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HHDBTsuE0XzNg/7G130cjkO+fnDnUgj1HoBLe6fjMoA=; b=Y8e6XCGKMyDP/m0MY5ws7PkrGJFpGBC7OsfyaZggw+lf0UlrdIKhfnwSIXlHmxgNZu 8Z5XYzgNAnG58dfC9uI8h2LaTiXHZjZ81VE9RqKTx991XLTDqJfMC0WdHsFnpP7Nbyuw uC0xddB3CKog7zyuxBiiefZgk6sOD+HUjyj3cCs3L/0OVJ48JTeFOnZIfM5hO8uqFs7q mJ6HhDm9ZOZZrnP0aJ2/PRz56JTiRtEsPm8UH0GWgn32FkueGhw5dnvqlSRCyACzjNuP kdbBkt2LHTfsFmMyhF3ChWJT9oOY7591uGY4pqJ5TU8Yxi74fU6JIocu+QZ2gDfKHcFq VpCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HHDBTsuE0XzNg/7G130cjkO+fnDnUgj1HoBLe6fjMoA=; b=b8vyjc0z3lGUQRFYRTCUGUNufvo7+jPjlFjQOJIizF04XOi5WD0GcDCf66rldVSVo0 WOIwHJlBdIrtNyqCPXth/OqaA9hBst1LLoWYH0fJm7NIdEAZQ8ABY220K4R41i1m8Ldy V+JLUNgKcaYfDUXF8vmYKchWkff/wwnO8Iq7uypsiVclepPzgPBQYgPmhKO1jxo/RNUD hvyXevEAIRF90iwgtG79QqOUoRuIuKz3n/o/YWjD1u6EYTU/jbWJnUX59ZLFFOi4APoE R2PaO8I0t2hPLPW9mQmUsdkoq63DM/HZEkQWcaaSgbMy4XKz8G3gesw1p692VipztrHV BSDg== X-Gm-Message-State: AElRT7FH5FrPy9zBhki1MMjZUD7cQuYXn7wcmcTzCKncPLLSkFIMxnrP 60EwS3FW2OsZzLAUgcchQHYU6g== X-Received: by 10.28.156.215 with SMTP id f206mr2920193wme.131.1520035999625; Fri, 02 Mar 2018 16:13:19 -0800 (PST) Received: from kusa.lan (AMontsouris-653-1-90-209.w86-212.abo.wanadoo.fr. [86.212.113.209]) by smtp.gmail.com with ESMTPSA id x78sm4091569wmd.2.2018.03.02.16.13.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Mar 2018 16:13:19 -0800 (PST) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Mar 2018 01:13:00 +0100 Message-Id: <20180303001300.4291-7-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180303001300.4291-1-matthieu.bouron@gmail.com> References: <20180303001300.4291-1-matthieu.bouron@gmail.com> Subject: [FFmpeg-devel] [PATCH 7/7] avcodec/mediacodecdec: factorize codec declarations 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 Cc: Matthieu Bouron MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/mediacodecdec.c | 116 ++++++++++----------------------------------- 1 file changed, 24 insertions(+), 92 deletions(-) diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index 4579da1fa5..5e9714ee6e 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -485,112 +485,44 @@ static const AVCodecHWConfigInternal *mediacodec_hw_configs[] = { NULL }; +#define DECLARE_MEDIACODEC_VDEC(short_name, full_name, codec_id, bsf) \ +AVCodec ff_##short_name##_mediacodec_decoder = { \ + .name = #short_name "_mediacodec", \ + .long_name = NULL_IF_CONFIG_SMALL(full_name "Android MediaCodec decoder"), \ + .type = AVMEDIA_TYPE_VIDEO, \ + .id = codec_id, \ + .priv_data_size = sizeof(MediaCodecH264DecContext), \ + .init = mediacodec_decode_init, \ + .receive_frame = mediacodec_receive_frame, \ + .flush = mediacodec_decode_flush, \ + .close = mediacodec_decode_close, \ + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, \ + .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, \ + .bsfs = bsf, \ + .hw_configs = mediacodec_hw_configs, \ + .wrapper_name = "mediacodec", \ +}; \ + #if CONFIG_H264_MEDIACODEC_DECODER -AVCodec ff_h264_mediacodec_decoder = { - .name = "h264_mediacodec", - .long_name = NULL_IF_CONFIG_SMALL("H.264 Android MediaCodec decoder"), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_H264, - .priv_data_size = sizeof(MediaCodecH264DecContext), - .init = mediacodec_decode_init, - .receive_frame = mediacodec_receive_frame, - .flush = mediacodec_decode_flush, - .close = mediacodec_decode_close, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, - .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, - .bsfs = "h264_mp4toannexb", - .hw_configs = mediacodec_hw_configs, - .wrapper_name = "mediacodec", -}; +DECLARE_MEDIACODEC_VDEC(h264, "H.264", AV_CODEC_ID_H264, "h264_mp4toannexb") #endif #if CONFIG_HEVC_MEDIACODEC_DECODER -AVCodec ff_hevc_mediacodec_decoder = { - .name = "hevc_mediacodec", - .long_name = NULL_IF_CONFIG_SMALL("H.265 Android MediaCodec decoder"), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_HEVC, - .priv_data_size = sizeof(MediaCodecH264DecContext), - .init = mediacodec_decode_init, - .receive_frame = mediacodec_receive_frame, - .flush = mediacodec_decode_flush, - .close = mediacodec_decode_close, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, - .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, - .bsfs = "hevc_mp4toannexb", - .hw_configs = mediacodec_hw_configs, - .wrapper_name = "mediacodec", -}; +DECLARE_MEDIACODEC_VDEC(hevc, "H.265", AV_CODEC_ID_HEVC, "hevc_mp4toannexb") #endif #if CONFIG_MPEG2_MEDIACODEC_DECODER -AVCodec ff_mpeg2_mediacodec_decoder = { - .name = "mpeg2_mediacodec", - .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 Android MediaCodec decoder"), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_MPEG2VIDEO, - .priv_data_size = sizeof(MediaCodecH264DecContext), - .init = mediacodec_decode_init, - .receive_frame = mediacodec_receive_frame, - .flush = mediacodec_decode_flush, - .close = mediacodec_decode_close, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, - .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, - .hw_configs = mediacodec_hw_configs, - .wrapper_name = "mediacodec", -}; +DECLARE_MEDIACODEC_VDEC(mpeg2, "MPEG-2", AV_CODEC_ID_MPEG2VIDEO, NULL) #endif #if CONFIG_MPEG4_MEDIACODEC_DECODER -AVCodec ff_mpeg4_mediacodec_decoder = { - .name = "mpeg4_mediacodec", - .long_name = NULL_IF_CONFIG_SMALL("MPEG-4 Android MediaCodec decoder"), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_MPEG4, - .priv_data_size = sizeof(MediaCodecH264DecContext), - .init = mediacodec_decode_init, - .receive_frame = mediacodec_receive_frame, - .flush = mediacodec_decode_flush, - .close = mediacodec_decode_close, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, - .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, - .hw_configs = mediacodec_hw_configs, - .wrapper_name = "mediacodec", -}; +DECLARE_MEDIACODEC_VDEC(mpeg4, "MPEG-4", AV_CODEC_ID_MPEG4, NULL) #endif #if CONFIG_VP8_MEDIACODEC_DECODER -AVCodec ff_vp8_mediacodec_decoder = { - .name = "vp8_mediacodec", - .long_name = NULL_IF_CONFIG_SMALL("VP8 Android MediaCodec decoder"), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_VP8, - .priv_data_size = sizeof(MediaCodecH264DecContext), - .init = mediacodec_decode_init, - .receive_frame = mediacodec_receive_frame, - .flush = mediacodec_decode_flush, - .close = mediacodec_decode_close, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, - .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, - .hw_configs = mediacodec_hw_configs, - .wrapper_name = "mediacodec", -}; +DECLARE_MEDIACODEC_VDEC(vp8, "VP8", AV_CODEC_ID_VP8, NULL) #endif #if CONFIG_VP9_MEDIACODEC_DECODER -AVCodec ff_vp9_mediacodec_decoder = { - .name = "vp9_mediacodec", - .long_name = NULL_IF_CONFIG_SMALL("VP9 Android MediaCodec decoder"), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_VP9, - .priv_data_size = sizeof(MediaCodecH264DecContext), - .init = mediacodec_decode_init, - .receive_frame = mediacodec_receive_frame, - .flush = mediacodec_decode_flush, - .close = mediacodec_decode_close, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, - .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS, - .hw_configs = mediacodec_hw_configs, - .wrapper_name = "mediacodec", -}; +DECLARE_MEDIACODEC_VDEC(vp9, "VP9", AV_CODEC_ID_VP9, NULL) #endif