From patchwork Sun Jan 30 06:27:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33914 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp1770450iov; Sat, 29 Jan 2022 22:30:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyt0dcRUSs/nEhwCdckVX9R+5b/PZHmBk7cW8AvtwBh+tPBB4XbnBz9B9XmCoM1M93hwS2O X-Received: by 2002:a17:907:16a3:: with SMTP id hc35mr13174619ejc.299.1643524212959; Sat, 29 Jan 2022 22:30:12 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id nc37si6146007ejc.697.2022.01.29.22.30.12; Sat, 29 Jan 2022 22:30:12 -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=@outlook.com header.s=selector1 header.b=n4BIUDPE; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EDD0F68B1A8; Sun, 30 Jan 2022 08:28:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2086.outbound.protection.outlook.com [40.92.90.86]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0B20468B18C for ; Sun, 30 Jan 2022 08:28:30 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RAHMGVaxV1SQnfPi7fK0/RR7QBQOhiA6r/XP33d/0ESAO+A2W53StJJF8eYGTlPjyfEL+KquQXfapPHGkoEb1H7Lq+QGvNHm1sxIoBefCyOBXy3pMmC2/OnHJjGVW/RTv8HJQeiKLc13Sd7LjpkGuX1h3z6oO447ZD/FlPqAuXVjyRLKQIOI5KQaHGwOqg+GJko10UgVZNxgvCO1ctWWnwdbdPO9PszWUx+NM6Ovt1qCO/zVt3juGWGY7Ns3MruF3VWyl6StzVRSF829p31tv/GVedVvg3Phaxr+FcauDr6XN9WOZDYF1HlzYO6KxshTo/2cyiFu5ATqGaGSxbkd+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l6uHVUI4KyVGxT9r11YLx2MerrKBr4EFbkRTzAX9MVo=; b=U8NUSPYD2zRSpJRfK3+9qfcazqIiMUFKJ3r0AIxdSle6Eo8msCHdS7I6mQbPaz5CCFUTO6FhUQrp9tEfWshgKJKyuQXN7KrjOKDN51t+32yJ5kTyo8gDjj/7qYQgR75UeEUlChatybGUX+L90KB1km+aFPMuo3adzL8kWUg7GZLdJmNXLTaGgCJkHaS7rYAljxmu9Obc9LEQ6bnVraU+Yg6+DCsTmZ2ykaq4/0RL54u/3swrS2Qbls4EvVNuf6S1WYkqM6Y2k0UvofqdIrumIwJdj0cMDtQVyW5g5qAd+hm5wuOL8OaGfKxklqB3u7OeLIkFoc8vH5kFmbPIYlXu3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l6uHVUI4KyVGxT9r11YLx2MerrKBr4EFbkRTzAX9MVo=; b=n4BIUDPEi+UYLDcplI4B29CXd1ad+u5QgMA23hAfbtjBeB8iGiAMub0fa9Kf5Sr1JJG0rKfSUtQaZvbClUaiatG6pjD+KRrBIzQJDvzZVhz7ALNOfILfzztvo2WxbNTZkqk+cF9+OKs9eltVlTrnF1A+ASE0D9Wx8iEdJMFzEeRDODpcXUa+6pqGt+dhG/ze2KLsAzJxmmW8XPCHS7yLxknGKYO0jOQOmt8E9uwMcgF8Qai9vuigBJsNc6n5/XsZ5rGBN00LUqYJYTmluBinvrSEcGjgbRmHjtpMnQWwNYRSq2CD5pfANXLlcoWIBiHwkAn7u0rgUkJEbBXOEsvhOA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by PAXPR03MB7666.eurprd03.prod.outlook.com (2603:10a6:102:202::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.20; Sun, 30 Jan 2022 06:28:28 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22%6]) with mapi id 15.20.4930.021; Sun, 30 Jan 2022 06:28:28 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 30 Jan 2022 07:27:21 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [0upNtHp1xzE9gxKzup49I5Tdof/z6BzH] X-ClientProxiedBy: AM6PR10CA0044.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:80::21) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220130062749.936489-12-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1bd0966e-40ee-44b4-9df7-08d9e3b9ba0f X-MS-TrafficTypeDiagnostic: PAXPR03MB7666:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: byCBFlADPphQwdlzyCuqZTDd26HwurW/srcvrt2aEvXV+21/C6tSQ9l2OBCs//OphXp1E7ydLNe7sxd2Z4MQTYzMeFNkKrJZ7mhemECs2eFE8bbQs7nx4ORnOk+eUw6sL4dBrm9XqBz6OGzZxySU5BzCk+FnUM4YPMTGbJ3XboyQJNTqRIwJR8yzAge+odM1phyqqWlg6jPZ6ZsFgLlqjwA6nzofLGrc1Z1JwOsDSBeE6eyHI+sOP1hQb8uePFIi22v/ahn9ndSXQ/d8VhqLC8HVmRvIGw+1PoBnKXnazFnQoNqVbZu1OM8McFnuwC/fCBbxKauGwLtfAFbjk97pIyBHufP/FsoxKGk48tuoFqrh2o7txSQqkFOiuNerA+PVD9Oirc2TMgB4KlIvdCBZ7/x8kUlxw/NhyNfk4XHI0ox6EDej+XeH8RgdDr+lwavuCGxSEBp9/l8bLobCSx2YIzMuesrUWzH0tvmcKS5kicjxJKnb1IOl7Iib42JeoFQFlRZdMB/K35gUxb7j8I1LLwmBuaT4I0OoYT0jycIU9sPIF/d1rLa7xku5Rj/gD/0t X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S+otLHIYSWfS2ew8F+sRMbitqi92vya7yPLhknNNS3oF1Z255pGU10JjrpIRbfVSy1DlworI/v4r4j/gMdOrySOpKCfqfn+2xlF1if6KGuc/LJ9b7tu+aSpHca87TlVhlOgoYW8BN9GSxgWjvSWnw1n18c/x+GHdJx3O5Iv4wo9KcgX8xm0+hfF6roAq2eOAbn49VGMpYadTtdTX9WliRI2DAjbmrL+VIXQMKZawnWHaueI0eT+0RP/zH9Zd5viabpOe1QxZOXIQf5vt3KK0IRLzlUwM+vsJSXHfmKvUxhx82LepOvBgiXZwF0KpCjXWen6DK/AC7fZN3eYRnCKIK+R60RifSx3066yEZ/ykdOzntKS8DTZHyAKNBtbXrGEC+K8qSXwvQqxDfjwXovtKGDGf5npedN1Fxc4Ex380SC3H6aw7e/Hk7DBBaQJh+tSDGD7SmHE6uDndTsp1Vm7bxoXI19S8Jd9Aj1mifnrEcCzfYmAg1hweqeMR56PehGxYrYF9dog4i6ZTUtNBIBQYyjuPe67ANChQ5kyLx6iLmb8XUx+fPY1k2MRI83ss5lV04Fhf9ryd77U4Bxm9t9IQRyct7OPoUC8laLcaxPUieVK18xtXj1abdXDJCAi6kJ47twnWWCJLOPrux5gNiWcuWxGYjF0KKQ/CSZE5524fSUAf34UTDE3gXsrEZ3CxYii8+6jWMqDjgNi3+2TXzefY2tR1hOgUmxfgDHuRuDKise+SSiRuh4EblHpBbvAXfNDLfYC1KtU7wMsG08vHJnkA/XEi1pS4ixfd8lGn8N1NU0a7nky8R/vHvtsvresVX3kwDfAe95BTn/wWG8ojNvazscPAe6RsHrk6JILB9ejrqedggyAT9+bo9DBnrHdTPh1VHMu4a0EMvl39LXDsHdp/FAWP+ZgbrN/qUHWNHPBJ4J9ivhFhEVsZE3j12Po9+Nas3AA4m20Ed1QiOvtgyQwsGQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1bd0966e-40ee-44b4-9df7-08d9e3b9ba0f X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2022 06:28:28.1706 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR03MB7666 Subject: [FFmpeg-devel] [PATCH 13/41] avcodec/mpegvideo: Move encoder-only stuff to a new header X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: vS8n/vtXccvY Signed-off-by: Andreas Rheinhardt --- libavcodec/dnxhdenc.c | 1 + libavcodec/flvdec.c | 1 + libavcodec/flvenc.c | 1 + libavcodec/h261enc.c | 1 + libavcodec/h263enc.h | 2 +- libavcodec/intelh263dec.c | 1 + libavcodec/ituh263enc.c | 1 + libavcodec/libxavs2.c | 2 + libavcodec/mdec.c | 1 + libavcodec/mjpegenc.c | 1 + libavcodec/motion_est.c | 2 +- libavcodec/mpeg12.h | 1 + libavcodec/mpeg12enc.c | 1 + libavcodec/mpeg4videoenc.c | 1 + libavcodec/mpegvideo.h | 126 ------------------------- libavcodec/mpegvideo_enc.c | 1 + libavcodec/mpegvideoenc.h | 161 ++++++++++++++++++++++++++++++++ libavcodec/msmpeg4enc.c | 1 + libavcodec/nvdec_mpeg12.c | 1 + libavcodec/nvdec_mpeg4.c | 1 + libavcodec/ratecontrol.c | 2 +- libavcodec/rv10enc.c | 1 + libavcodec/rv20enc.c | 1 + libavcodec/rv30.c | 1 + libavcodec/rv40.c | 1 + libavcodec/speedhqenc.c | 1 + libavcodec/vaapi_encode_mpeg2.c | 2 + libavcodec/wmv2enc.c | 1 + libavcodec/x86/mpegvideoenc.c | 2 +- 29 files changed, 190 insertions(+), 130 deletions(-) create mode 100644 libavcodec/mpegvideoenc.h diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index ca67964330..ac92474e56 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -34,6 +34,7 @@ #include "fdctdsp.h" #include "internal.h" #include "mpegvideo.h" +#include "mpegvideoenc.h" #include "pixblockdsp.h" #include "packet_internal.h" #include "profiles.h" diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index 2bd86b5b47..108cf88e34 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -22,6 +22,7 @@ #include "flv.h" #include "h263dec.h" +#include "internal.h" #include "mpegvideo.h" #include "mpegvideodata.h" diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index 158b399c40..6824327734 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -22,6 +22,7 @@ #include "h263data.h" #include "mpegvideo.h" #include "mpegvideodata.h" +#include "mpegvideoenc.h" void ff_flv_encode_picture_header(MpegEncContext *s, int picture_number) { diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index 7e3af1ff9e..710d292df6 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -33,6 +33,7 @@ #include "mpegvideo.h" #include "h261.h" #include "mpegvideodata.h" +#include "mpegvideoenc.h" static uint8_t uni_h261_rl_len [64*64*2*2]; #define UNI_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level)) diff --git a/libavcodec/h263enc.h b/libavcodec/h263enc.h index 31f00665ce..fff85a18f2 100644 --- a/libavcodec/h263enc.h +++ b/libavcodec/h263enc.h @@ -22,7 +22,7 @@ #include #include "h263data.h" -#include "mpegvideo.h" +#include "mpegvideoenc.h" void ff_h263_encode_init(MpegEncContext *s); void ff_h263_encode_picture_header(MpegEncContext *s, int picture_number); diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c index 9dde247298..b61effa4df 100644 --- a/libavcodec/intelh263dec.c +++ b/libavcodec/intelh263dec.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" #include "h263data.h" diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 70ac1f643b..ef7caf8009 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -34,6 +34,7 @@ #include "avcodec.h" #include "mpegvideo.h" #include "mpegvideodata.h" +#include "mpegvideoenc.h" #include "h263.h" #include "h263enc.h" #include "h263data.h" diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c index 9c5a576e90..4742b18f9f 100644 --- a/libavcodec/libxavs2.c +++ b/libavcodec/libxavs2.c @@ -24,8 +24,10 @@ #include "xavs2.h" #include "encode.h" +#include "internal.h" #include "mpeg12.h" #include "libavutil/avstring.h" +#include "libavutil/opt.h" #define xavs2_opt_set2(name, format, ...) do{ \ char opt_str[16] = {0}; \ diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c index 007e7fada8..f340bdf385 100644 --- a/libavcodec/mdec.c +++ b/libavcodec/mdec.c @@ -33,6 +33,7 @@ #include "blockdsp.h" #include "bswapdsp.h" #include "idctdsp.h" +#include "internal.h" #include "mpeg12.h" #include "mpeg12data.h" #include "thread.h" diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 6a47503ab4..b9b17a50df 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -39,6 +39,7 @@ #include "mpegvideo.h" #include "mjpeg.h" #include "mjpegenc.h" +#include "mpegvideoenc.h" #include "profiles.h" /* The following is the private context of MJPEG/AMV decoder. diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 5b0958733c..35ca40b90a 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -36,7 +36,7 @@ #include "mathops.h" #include "motion_est.h" #include "mpegutils.h" -#include "mpegvideo.h" +#include "mpegvideoenc.h" #define P_LEFT P[1] #define P_TOP P[2] diff --git a/libavcodec/mpeg12.h b/libavcodec/mpeg12.h index fb2b37e7c8..7ab2527a36 100644 --- a/libavcodec/mpeg12.h +++ b/libavcodec/mpeg12.h @@ -24,6 +24,7 @@ #include "mpeg12vlc.h" #include "mpegvideo.h" +#include "rl.h" /* Start codes. */ #define SEQ_END_CODE 0x000001b7 diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 9c0be69ded..3ec3ac1860 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -43,6 +43,7 @@ #include "mpeg12data.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideoenc.h" #include "profiles.h" #if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 8a1a6cbcc8..d09e20605d 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -30,6 +30,7 @@ #include "h263enc.h" #include "mpeg4video.h" #include "mpeg4videodata.h" +#include "mpegvideoenc.h" #include "profiles.h" /* The uni_DCtab_* tables below contain unified bits+length tables to encode DC diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index f5c9789fea..18d2d0902f 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -39,7 +39,6 @@ #include "h263dsp.h" #include "hpeldsp.h" #include "idctdsp.h" -#include "internal.h" #include "me_cmp.h" #include "motion_est.h" #include "mpegpicture.h" @@ -54,11 +53,8 @@ #endif #include "mpegutils.h" #include "qpeldsp.h" -#include "rl.h" #include "videodsp.h" -#include "libavutil/opt.h" - #define MAX_THREADS 32 #define MAX_B_FRAMES 16 @@ -558,101 +554,6 @@ typedef struct MpegEncContext { #endif } MpegEncContext; -/* mpegvideo_enc common options */ -#define FF_MPV_FLAG_SKIP_RD 0x0001 -#define FF_MPV_FLAG_STRICT_GOP 0x0002 -#define FF_MPV_FLAG_QP_RD 0x0004 -#define FF_MPV_FLAG_CBP_RD 0x0008 -#define FF_MPV_FLAG_NAQ 0x0010 -#define FF_MPV_FLAG_MV0 0x0020 - -#define FF_MPV_OPT_CMP_FUNC \ -{ "sad", "Sum of absolute differences, fast", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "sse", "Sum of squared errors", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "satd", "Sum of absolute Hadamard transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SATD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "dct", "Sum of absolute DCT transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCT }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "psnr", "Sum of squared quantization errors, low quality", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_PSNR }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "bit", "Number of bits needed for the block", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_BIT }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "rd", "Rate distortion optimal, slow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_RD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "zero", "Zero", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_ZERO }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "vsad", "Sum of absolute vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "vsse", "Sum of squared vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "nsse", "Noise preserving sum of squared differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_NSSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "dct264", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCT264 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "dctmax", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_CHROMA }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{ "msad", "Sum of absolute differences, median predicted", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_MEDIAN_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" } - -#ifndef FF_MPV_OFFSET -#define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x) -#endif -#define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) -#define FF_MPV_COMMON_OPTS \ -FF_MPV_OPT_CMP_FUNC, \ -{ "mpv_flags", "Flags common for all mpegvideo-based encoders.", FF_MPV_OFFSET(mpv_flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "skip_rd", "RD optimal MB level residual skipping", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_SKIP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "strict_gop", "Strictly enforce gop size", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_STRICT_GOP }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "qp_rd", "Use rate distortion optimization for qp selection", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_QP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "cbp_rd", "use rate distortion optimization for CBP", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_CBP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "naq", "normalize adaptive quantization", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_NAQ }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "mv0", "always try a mb with mv=<0,0>", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_MV0 }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ -{ "luma_elim_threshold", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)",\ - FF_MPV_OFFSET(luma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\ -{ "chroma_elim_threshold", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)",\ - FF_MPV_OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\ -{ "quantizer_noise_shaping", NULL, FF_MPV_OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },\ -{ "error_rate", "Simulate errors in the bitstream to test error concealment.", \ - FF_MPV_OFFSET(error_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },\ -{"qsquish", "how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)", \ - FF_MPV_OFFSET(rc_qsquish), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, 0, 99, FF_MPV_OPT_FLAGS}, \ -{"rc_qmod_amp", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_amp), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"rc_qmod_freq", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_freq), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS}, \ -{"rc_eq", "Set rate control equation. When computing the expression, besides the standard functions " \ - "defined in the section 'Expression Evaluation', the following functions are available: " \ - "bits2qp(bits), qp2bits(qp). Also the following constants are available: iTex pTex tex mv " \ - "fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex avgTex.", \ - FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, .flags = FF_MPV_OPT_FLAGS }, \ -{"rc_init_cplx", "initial complexity for 1-pass encoding", FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"rc_buf_aggressivity", "currently useless", FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"border_mask", "increase the quantizer for macroblocks close to borders", FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ -{"lmin", "minimum Lagrange factor (VBR)", FF_MPV_OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 2*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"lmax", "maximum Lagrange factor (VBR)", FF_MPV_OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"ibias", "intra quant bias", FF_MPV_OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"pbias", "inter quant bias", FF_MPV_OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"motion_est", "motion estimation algorithm", FF_MPV_OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, FF_MPV_OPT_FLAGS, "motion_est" }, \ -{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ -{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ -{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ -{"skip_threshold", "Frame skip threshold", FF_MPV_OFFSET(frame_skip_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"skip_factor", "Frame skip factor", FF_MPV_OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"skip_exp", "Frame skip exponent", FF_MPV_OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"skip_cmp", "Frame skip compare function", FF_MPV_OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ -{"sc_threshold", "Scene change threshold", FF_MPV_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"noise_reduction", "Noise reduction", FF_MPV_OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"ps", "RTP payload size in bytes", FF_MPV_OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", FF_MPV_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"mepre", "pre motion estimation", FF_MPV_OFFSET(me_pre), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"intra_penalty", "Penalty for intra blocks in block decision", FF_MPV_OFFSET(intra_penalty), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX/2, FF_MPV_OPT_FLAGS }, \ - -#define FF_MPV_COMMON_BFRAME_OPTS \ -{"b_strategy", "Strategy to choose between I/P/B-frames", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \ -{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \ -{"brd_scale", "Downscale frames for dynamic B-frame decision", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS }, - -#if FF_API_MPEGVIDEO_OPTS -#define FF_MPV_DEPRECATED_MPEG_QUANT_OPT \ - { "mpeg_quant", "Deprecated, does nothing", FF_MPV_OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, -#define FF_MPV_DEPRECATED_A53_CC_OPT \ - { "a53cc", "Deprecated, does nothing", FF_MPV_OFFSET(dummy), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, -#define FF_MPV_DEPRECATED_MATRIX_OPT \ - { "force_duplicated_matrix", "Deprecated, does nothing", FF_MPV_OFFSET(dummy), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, -#define FF_MPV_DEPRECATED_BFRAME_OPTS \ - { "b_strategy", "Deprecated, does nothing", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \ - { "b_sensitivity", "Deprecated, does nothing", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, { .i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \ - { "brd_scale", "Deprecated, does nothing", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, -#endif - -extern const AVClass ff_mpv_enc_class; /** * Set the given MpegEncContext to common defaults (same for encoding @@ -661,8 +562,6 @@ extern const AVClass ff_mpv_enc_class; */ void ff_mpv_common_defaults(MpegEncContext *s); -void ff_dct_encode_init_x86(MpegEncContext *s); - int ff_mpv_common_init(MpegEncContext *s); void ff_mpv_common_init_arm(MpegEncContext *s); void ff_mpv_common_init_axp(MpegEncContext *s); @@ -703,14 +602,6 @@ void ff_mpv_report_decode_progress(MpegEncContext *s); int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx); void ff_mpv_frame_end(MpegEncContext *s); -int ff_mpv_encode_init(AVCodecContext *avctx); -void ff_mpv_encode_init_x86(MpegEncContext *s); - -int ff_mpv_encode_end(AVCodecContext *avctx); -int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, - const AVFrame *frame, int *got_packet); -int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase); - void ff_clean_intra_table_entries(MpegEncContext *s); void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h); void ff_mpeg_flush(AVCodecContext *avctx); @@ -719,19 +610,11 @@ void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict); int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type); -void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix); - int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src); int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); void ff_set_qscale(MpegEncContext * s, int qscale); void ff_mpv_idct_init(MpegEncContext *s); -int ff_dct_encode_init(MpegEncContext *s); -void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64], - const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra); -int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow); -void ff_block_permute(int16_t *block, uint8_t *permutation, - const uint8_t *scantable, int last); void ff_init_block_index(MpegEncContext *s); void ff_mpv_motion(MpegEncContext *s, @@ -756,15 +639,6 @@ static inline void ff_update_block_index(MpegEncContext *s){ s->dest[2]+= (2 >> s->chroma_x_shift) * block_size; } -static inline int get_bits_diff(MpegEncContext *s){ - const int bits= put_bits_count(&s->pb); - const int last= s->last_bits; - - s->last_bits = bits; - - return bits - last; -} - static inline int mpeg_get_qscale(MpegEncContext *s) { int qscale = get_bits(&s->gb, 5); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 5717b7422e..a76b4b9f60 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -48,6 +48,7 @@ #include "mpeg12data.h" #include "mpegvideo.h" #include "mpegvideodata.h" +#include "mpegvideoenc.h" #include "h261.h" #include "h263.h" #include "h263data.h" diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h new file mode 100644 index 0000000000..21e7a55e13 --- /dev/null +++ b/libavcodec/mpegvideoenc.h @@ -0,0 +1,161 @@ +/* + * Generic DCT based hybrid video encoder + * Copyright (c) 2000, 2001, 2002 Fabrice Bellard + * Copyright (c) 2002-2004 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * mpegvideo header. + */ + +#ifndef AVCODEC_MPEGVIDEOENC_H +#define AVCODEC_MPEGVIDEOENC_H + +#include "libavutil/opt.h" +#include "internal.h" +#include "mpegvideo.h" + +/* mpegvideo_enc common options */ +#define FF_MPV_FLAG_SKIP_RD 0x0001 +#define FF_MPV_FLAG_STRICT_GOP 0x0002 +#define FF_MPV_FLAG_QP_RD 0x0004 +#define FF_MPV_FLAG_CBP_RD 0x0008 +#define FF_MPV_FLAG_NAQ 0x0010 +#define FF_MPV_FLAG_MV0 0x0020 + +#define FF_MPV_OPT_CMP_FUNC \ +{ "sad", "Sum of absolute differences, fast", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "sse", "Sum of squared errors", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "satd", "Sum of absolute Hadamard transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_SATD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "dct", "Sum of absolute DCT transformed differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCT }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "psnr", "Sum of squared quantization errors, low quality", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_PSNR }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "bit", "Number of bits needed for the block", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_BIT }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "rd", "Rate distortion optimal, slow", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_RD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "zero", "Zero", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_ZERO }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "vsad", "Sum of absolute vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "vsse", "Sum of squared vertical differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_VSSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "nsse", "Noise preserving sum of squared differences", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_NSSE }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "dct264", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCT264 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "dctmax", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "chroma", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_CHROMA }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{ "msad", "Sum of absolute differences, median predicted", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CMP_MEDIAN_SAD }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" } + +#ifndef FF_MPV_OFFSET +#define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x) +#endif +#define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) +#define FF_MPV_COMMON_OPTS \ +FF_MPV_OPT_CMP_FUNC, \ +{ "mpv_flags", "Flags common for all mpegvideo-based encoders.", FF_MPV_OFFSET(mpv_flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "skip_rd", "RD optimal MB level residual skipping", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_SKIP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "strict_gop", "Strictly enforce gop size", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_STRICT_GOP }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "qp_rd", "Use rate distortion optimization for qp selection", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_QP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "cbp_rd", "use rate distortion optimization for CBP", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_CBP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "naq", "normalize adaptive quantization", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_NAQ }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "mv0", "always try a mb with mv=<0,0>", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_MV0 }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\ +{ "luma_elim_threshold", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)",\ + FF_MPV_OFFSET(luma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\ +{ "chroma_elim_threshold", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)",\ + FF_MPV_OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\ +{ "quantizer_noise_shaping", NULL, FF_MPV_OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },\ +{ "error_rate", "Simulate errors in the bitstream to test error concealment.", \ + FF_MPV_OFFSET(error_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },\ +{"qsquish", "how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)", \ + FF_MPV_OFFSET(rc_qsquish), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, 0, 99, FF_MPV_OPT_FLAGS}, \ +{"rc_qmod_amp", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_amp), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ +{"rc_qmod_freq", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_freq), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS}, \ +{"rc_eq", "Set rate control equation. When computing the expression, besides the standard functions " \ + "defined in the section 'Expression Evaluation', the following functions are available: " \ + "bits2qp(bits), qp2bits(qp). Also the following constants are available: iTex pTex tex mv " \ + "fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex avgTex.", \ + FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, .flags = FF_MPV_OPT_FLAGS }, \ +{"rc_init_cplx", "initial complexity for 1-pass encoding", FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ +{"rc_buf_aggressivity", "currently useless", FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ +{"border_mask", "increase the quantizer for macroblocks close to borders", FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ +{"lmin", "minimum Lagrange factor (VBR)", FF_MPV_OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 2*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"lmax", "maximum Lagrange factor (VBR)", FF_MPV_OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"ibias", "intra quant bias", FF_MPV_OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"pbias", "inter quant bias", FF_MPV_OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"motion_est", "motion estimation algorithm", FF_MPV_OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, FF_MPV_OPT_FLAGS, "motion_est" }, \ +{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ +{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ +{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ +{"skip_threshold", "Frame skip threshold", FF_MPV_OFFSET(frame_skip_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"skip_factor", "Frame skip factor", FF_MPV_OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"skip_exp", "Frame skip exponent", FF_MPV_OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"skip_cmp", "Frame skip compare function", FF_MPV_OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "cmp_func" }, \ +{"sc_threshold", "Scene change threshold", FF_MPV_OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"noise_reduction", "Noise reduction", FF_MPV_OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"ps", "RTP payload size in bytes", FF_MPV_OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"mepc", "Motion estimation bitrate penalty compensation (1.0 = 256)", FF_MPV_OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"mepre", "pre motion estimation", FF_MPV_OFFSET(me_pre), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"intra_penalty", "Penalty for intra blocks in block decision", FF_MPV_OFFSET(intra_penalty), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX/2, FF_MPV_OPT_FLAGS }, \ + +#define FF_MPV_COMMON_BFRAME_OPTS \ +{"b_strategy", "Strategy to choose between I/P/B-frames", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \ +{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \ +{"brd_scale", "Downscale frames for dynamic B-frame decision", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS }, + +#if FF_API_MPEGVIDEO_OPTS +#define FF_MPV_DEPRECATED_MPEG_QUANT_OPT \ + { "mpeg_quant", "Deprecated, does nothing", FF_MPV_OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 0, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, +#define FF_MPV_DEPRECATED_A53_CC_OPT \ + { "a53cc", "Deprecated, does nothing", FF_MPV_OFFSET(dummy), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, +#define FF_MPV_DEPRECATED_MATRIX_OPT \ + { "force_duplicated_matrix", "Deprecated, does nothing", FF_MPV_OFFSET(dummy), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, +#define FF_MPV_DEPRECATED_BFRAME_OPTS \ + { "b_strategy", "Deprecated, does nothing", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \ + { "b_sensitivity", "Deprecated, does nothing", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, { .i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, \ + { "brd_scale", "Deprecated, does nothing", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS | AV_OPT_FLAG_DEPRECATED }, +#endif + +extern const AVClass ff_mpv_enc_class; + +int ff_mpv_encode_init(AVCodecContext *avctx); +void ff_mpv_encode_init_x86(MpegEncContext *s); + +int ff_mpv_encode_end(AVCodecContext *avctx); +int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, + const AVFrame *frame, int *got_packet); +int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase); + +void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix); + +int ff_dct_encode_init(MpegEncContext *s); +void ff_dct_encode_init_x86(MpegEncContext *s); + +int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow); +void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64], + const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra); + +void ff_block_permute(int16_t *block, uint8_t *permutation, + const uint8_t *scantable, int last); + +static inline int get_bits_diff(MpegEncContext *s) +{ + const int bits = put_bits_count(&s->pb); + const int last = s->last_bits; + + s->last_bits = bits; + + return bits - last; +} + +#endif diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c index 16e19083da..5e1ed9cc27 100644 --- a/libavcodec/msmpeg4enc.c +++ b/libavcodec/msmpeg4enc.c @@ -34,6 +34,7 @@ #include "libavutil/avutil.h" #include "libavutil/thread.h" #include "mpegvideo.h" +#include "mpegvideoenc.h" #include "h263.h" #include "h263enc.h" #include "internal.h" diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c index 9a9030d8d3..b8db4250bb 100644 --- a/libavcodec/nvdec_mpeg12.c +++ b/libavcodec/nvdec_mpeg12.c @@ -21,6 +21,7 @@ */ #include "avcodec.h" +#include "internal.h" #include "mpegvideo.h" #include "nvdec.h" #include "decode.h" diff --git a/libavcodec/nvdec_mpeg4.c b/libavcodec/nvdec_mpeg4.c index 739b049933..2b2b1b87a1 100644 --- a/libavcodec/nvdec_mpeg4.c +++ b/libavcodec/nvdec_mpeg4.c @@ -21,6 +21,7 @@ */ #include "avcodec.h" +#include "internal.h" #include "mpeg4video.h" #include "nvdec.h" #include "decode.h" diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index 6b77ccd006..f814e23ed5 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -32,7 +32,7 @@ #include "internal.h" #include "ratecontrol.h" #include "mpegutils.h" -#include "mpegvideo.h" +#include "mpegvideoenc.h" #include "libavutil/eval.h" void ff_write_pass1_stats(MpegEncContext *s) diff --git a/libavcodec/rv10enc.c b/libavcodec/rv10enc.c index 72b25e0c55..0c74da1b3c 100644 --- a/libavcodec/rv10enc.c +++ b/libavcodec/rv10enc.c @@ -26,6 +26,7 @@ */ #include "mpegvideo.h" +#include "mpegvideoenc.h" #include "put_bits.h" #include "rv10.h" diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c index 204cd03a24..9f935d61e2 100644 --- a/libavcodec/rv20enc.c +++ b/libavcodec/rv20enc.c @@ -27,6 +27,7 @@ #include "mpegvideo.h" #include "mpegvideodata.h" +#include "mpegvideoenc.h" #include "h263data.h" #include "h263enc.h" #include "put_bits.h" diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c index 751647bebe..d11b8430e7 100644 --- a/libavcodec/rv30.c +++ b/libavcodec/rv30.c @@ -25,6 +25,7 @@ */ #include "avcodec.h" +#include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" #include "golomb.h" diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c index 31a7a04e51..0b3f733bc6 100644 --- a/libavcodec/rv40.c +++ b/libavcodec/rv40.c @@ -29,6 +29,7 @@ #include "libavutil/imgutils.h" #include "avcodec.h" +#include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" #include "golomb.h" diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 967774931c..806eae7cf1 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -34,6 +34,7 @@ #include "mpeg12.h" #include "mpeg12data.h" #include "mpegvideo.h" +#include "mpegvideoenc.h" #include "speedhqenc.h" extern RLTable ff_rl_speedhq; diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index af3a63dab7..d084d8c4b9 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -20,10 +20,12 @@ #include #include "libavutil/avassert.h" +#include "libavutil/opt.h" #include "avcodec.h" #include "cbs.h" #include "cbs_mpeg2.h" +#include "internal.h" #include "mpeg12.h" #include "vaapi_encode.h" diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c index d6962448a6..d8481301e1 100644 --- a/libavcodec/wmv2enc.c +++ b/libavcodec/wmv2enc.c @@ -21,6 +21,7 @@ #include "avcodec.h" #include "h263.h" #include "mpegvideo.h" +#include "mpegvideoenc.h" #include "msmpeg4.h" #include "msmpeg4enc.h" #include "msmpeg4data.h" diff --git a/libavcodec/x86/mpegvideoenc.c b/libavcodec/x86/mpegvideoenc.c index 4bad6a87ef..3691cce26c 100644 --- a/libavcodec/x86/mpegvideoenc.c +++ b/libavcodec/x86/mpegvideoenc.c @@ -26,7 +26,7 @@ #include "libavutil/x86/cpu.h" #include "libavcodec/avcodec.h" #include "libavcodec/dct.h" -#include "libavcodec/mpegvideo.h" +#include "libavcodec/mpegvideoenc.h" /* not permutated inverse zigzag_direct + 1 for MMX quantizer */ DECLARE_ALIGNED(16, static const uint16_t, inv_zigzag_direct16)[64] = {