From patchwork Sat Feb 10 23:04:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46167 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:a586:b0:19e:8a94:b663 with SMTP id gd6csp1752888pzc; Sat, 10 Feb 2024 15:03:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUo7ZyJwBoQA1kQnoWiTYh4sVk85PfVigFZVgQHOC7/NN8jw6yaQYuTJWT8Lep9Up48sQH X-Received: by 2002:a17:906:3493:b0:a3c:6015:4d07 with SMTP id g19-20020a170906349300b00a3c60154d07mr426740ejb.54.1707606206519; Sat, 10 Feb 2024 15:03:26 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXo87D6wFf/zpIDbDsUNyyOExsEBhQGI9ultHMPCsaSYnTY0kENNn7dW6s36Dm0tMOGqGy6IaKFbtRq2kFWQY75rx7bmREasxRL4bNINbUcSuGBdxHANz+xDCBKGREb1+AshP+gbKNLOL+d2FFiTUi51JhMu9ATERsJV6MCHm1a4dN4+9jFNrrD28xLwBxDnXSuV8CDv+Btb9yP6dAc/QmDvqq9N8BMSJMdjIYrNluxzSj/YERNBF7hHBm0qkaoMIE2UyGFWlNkSTDJWE5M2whcCe929DLlk/sPSrFJBcnGVlX1E95uP7kD+QFxwGD9P1fZ5OBVuEn43J7MPC5mOWY484SAyynzWx4lVZ2ZxCs8TUeKzcMh+jj+aF0vEH4Dhni02T0DzPwlXDHN16tah+ASk0gdvmMSVbRmnGpt+OnJYJcDuL9zUpEq5/bpZehh7A2KjD1bOTZ//MUSyKfiGu2SbHcTJICrUWbq8dBiUvKJfXdw3JBV9YCRVvv29Dc39cXHkmQ2CGlIFIQ0gsBYNHRqLv1z+fHjUSsaK4TDlryf5/12rkOWuwMr9ng9yAdJtV/TqgvaLy7xnqVnWf5xbDeBSL5VtKR1swHJwDK+1QLLrui+PFuNwNJ2D/d3hzwbwuhtIeNEt6PxcR56DKSy3fBtxP+Gw60BDT1rcdlbMZiTolBoGEjKokHkz1Hd20JsQ7CWZkFCOq+WEnVIzOvv37C0TrWmoggQGsXKkJgIdUg4gG0FQ54G/s1segYSJSiP3Zh4V193ixrejjrq5EVBl8VjMgTVqUBWs/neI8QcCYvyiWZR1Nx6YPpiTm5mGafwxpVqz/FdlkqjfrIQJ1vAMpJ25e2ma620sja5kpIjXU0ncVz9+yuFLzJXRXZMTW+iMFNY3uJV+M/DUNgxqjwDMRoTFKCIuT40gBb68M9oZ1x1ihbzhJFsNsa3/KbIE82n7VDu4P HfMixsUkEfmHRp0mfDrKfP/efyLkIiGQ9aQhfBK1LAd1FpILVgY+/QGPYL/C7o+2xbXCkKqahV9U+ODycV7zpVovDtagrokQUAo14oi6CdWPI9iRq6mO9XRkK7v16DSb02vFC/3M815i4xpjHQE/5Xn3izX/+IVgShdV4afKw52VVrJKn5qA4dKN89rcjfjWK4tYThvRo0CjQkU7YL9pPSzI9GYgofB43TC7B8kiLs8YYz/f2NHDkiOjGXTj944mSkrzhgKTikX3wj0KEPX7jkaEJaYNrG/L62XJydzcfPgaRy3GKKXWOPUZyPSQDH792eW3ykdUrEWNXoRNXxt30ocoXDxW1dfWLuCNW90FHUWbxSDnC1/AfctayROQljLsOc/xsPoa0W8jJwCm84oqPvBJ2KiLXnX7Olfoz++p6gGgQUZqQo12EOQQhFCelJ/y9/9wb9jxL4H5/Kmch/30RSLrdQfeuwbtRKiG1EY8H3ajJ3yPijPfTj7S35XSJHLOFzCgAW2Kj7o0trCvOolCSBClCOtmTG/XyiSpmidYvzFBoETATeZy+VpBB1qkoLaEvtb8HAjdkMS5WKogjZLOfRt6spzHt7qn9PRQ== Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hv12-20020a17090760cc00b00a3c2f685485si1022647ejc.201.2024.02.10.15.03.26; Sat, 10 Feb 2024 15:03:26 -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=DUOCkYlj; 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 BFBE568D152; Sun, 11 Feb 2024 01:02:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04olkn2040.outbound.protection.outlook.com [40.92.73.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7319F68D15E for ; Sun, 11 Feb 2024 01:02:51 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IiHvQPlUalXCTeEIAHR1y41yL8O79NjAVXYGFMsCSs16GbLbz1C0sNAVXf93iczDHIpozYi2vYD7CHzhonVgQZULPTXYogcMshz56oG69UteUYDkH0cUPkbFoFWVj2tgPfPWl9VxZfBiAvfqXmiBpxg0uPmq1lSZyOj04YNSHKqupsu384C0vU2xvqevOgnk+XNB/+JAtbLyYZWIEDYL/vGL7vjcdfUlqz99bwiDnbyOwuHmm2RDB6z5pm+eZTtivouspMrOuJmJnokxay8hVJJ/Rm6fnFYrBZl86ZVPnYqn77N0lxlGToMT98hgBdWdnxsDLDItFSMrp6NQy7U0Uw== 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=EnLDz3dQvbFH2NKvcsMv5LG5ipUdHLKoMYGiQy3a2LU=; b=RhadaLUJxv1BoEfQJaLDKIXAdo0y3ExcVsTmJHbRBanSh1lvNvnG55uCRrwUer+Rh3+hpIujbL4HwrocSMBtfADFnF5w1ynl+6Vvj637V+b0ohuMJdOTT+pkjWZ18LJB2mppdVism+1ll38+L48cez8G5EbDcBeWiWebEcdxqmZuzb7owQ7hgexR/Gw5lCZ6tIVMmosWvH6sU4scyc4Fk8v4S8S4QHl1Yll8KfS0TGqrguiuro5IoiDBvIT1++aMP5mKtAVFtTPMKk0QIh34guXsN+aqDVlv33nLBssJ2CRikpKR7p8vo/oAstrSvSe7B5FKQbzF7vQ7de6NiHFM1Q== 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=EnLDz3dQvbFH2NKvcsMv5LG5ipUdHLKoMYGiQy3a2LU=; b=DUOCkYljcM0pkpWEv1p0gsYTZz6GjxxsgN5Hb+OJ/Q5KkU8tqGnyWjK3FdMhgG9kfCGijb8NOYtQ+02ZIDvGJGlBD0az58EDIshTD8wbAxaFfnbV3/XptDQxP5XjblXgdSi/bMiLAFt8+oSAyy5SZkHMq7XLZ4PAWXMS9d4u3GqKq35ccSLcAYUFgNgKNKvL8YJUtqc+KVJNC3lpFHGUIgj5cJr5gNTkmkVHAiSB3P4HWEfxTyMHmPUzEX1DAJtw4Dqqj6d1HTV11bQm+VWw4AhaxbOXNaWzmeePbYB5oY1js3wJXnSD3R50NFlMR/sICgDlsoHxY3SAbPHyf+M/qQ== Received: from DU0P250MB0747.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:3cb::16) by AS8P250MB0037.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:37f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.33; Sat, 10 Feb 2024 23:02:48 +0000 Received: from DU0P250MB0747.EURP250.PROD.OUTLOOK.COM ([fe80::db07:87f6:7c75:38cc]) by DU0P250MB0747.EURP250.PROD.OUTLOOK.COM ([fe80::db07:87f6:7c75:38cc%3]) with mapi id 15.20.7270.033; Sat, 10 Feb 2024 23:02:48 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 11 Feb 2024 00:04:10 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240125134425.374-1-jamrial@gmail.com> References: <20240125134425.374-1-jamrial@gmail.com> X-TMN: [ItEgHC9y7yzXqXq+Ans8sth2Qa/GNmCq6CnG5L52fmk=] X-ClientProxiedBy: ZR2P278CA0003.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:50::6) To DU0P250MB0747.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:3cb::16) X-Microsoft-Original-Message-ID: <20240210230411.2616270-7-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0P250MB0747:EE_|AS8P250MB0037:EE_ X-MS-Office365-Filtering-Correlation-Id: 599cda2d-1217-4873-ee89-08dc2a8c66a9 X-MS-Exchange-SLBlob-MailProps: 9IecXKUgicCxfSlM0Mf+zc92VeVIBtN2Utoo4PySODx1zB+wik7ZNMSbtiUYTd2m6hH3MPa3jqj6Tqqh1d8usEjbfqoc6VJrQXnwOEkMIv+0jl0yfsBxBqwV3R//UYFYLJwg3yZiYU55k3MgYHxh/9LEMgR7428LEMC3bhCs1A0qk4MBaJ5OKtIjgPYRY1O882RWj/cyrIt8nf9Tjux7KXfr7g91GPf7z8UrVfDhhAilut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5HjwEcj7wtCOc9++UKW/XppWvlqEVbp5qJu9UXE7ily2izJfXXq21wM3RHOi+BojR80910Gjb/UjKJ9pNXIFSoQgaiPKJacu6+BZQvCOnBiuGowwOCTO8tSS3SpooGjozRe0EWxADR7bPYqXS3hp8cVhPcAwpteWCCMpGKaWCL8DWlN990yjeAdLv5uwcxG86tQoxdOBP9Gla/C9Gvq9NBBRwsPpH9dURQK8ZMbeKsESUFoTbqhZ539qtm9RWS5V794g8q3PGZGZxN0yIzOEGwMYrVyOy+RUD6GzKP6hlPypkhuqY4GVy042RwepSD6b+/LPNJfaJvK4XoPpGoR4hJ5NZVzpqE31PLIBKDQxyGdx+M1627hbqQQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 599cda2d-1217-4873-ee89-08dc2a8c66a9 X-MS-Exchange-CrossTenant-AuthSource: DU0P250MB0747.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2024 23:02:48.7951 (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: AS8P250MB0037 Subject: [FFmpeg-devel] [PATCH 34/35] avcodec/avcodec: Reorder AVCodecContext and AVSubtitleRect fields 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: vNdjZPkTXhxH Move related fields closer together and try to plug holes. Signed-off-by: Andreas Rheinhardt --- libavcodec/avcodec.h | 585 +++++++++++++++++++++---------------------- 1 file changed, 292 insertions(+), 293 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 431fc11de6..6706061ecc 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -490,29 +490,6 @@ typedef struct AVCodecContext { */ int64_t bit_rate; - /** - * number of bits the bitstream is allowed to diverge from the reference. - * the reference can be CBR (for CBR pass1) or VBR (for pass2) - * - encoding: Set by user; unused for constant quantizer encoding. - * - decoding: unused - */ - int bit_rate_tolerance; - - /** - * Global quality for codecs which cannot change it per frame. - * This should be proportional to MPEG-1/2/4 qscale. - * - encoding: Set by user. - * - decoding: unused - */ - int global_quality; - - /** - * - encoding: Set by user. - * - decoding: unused - */ - int compression_level; -#define FF_COMPRESSION_DEFAULT -1 - /** * AV_CODEC_FLAG_*. * - encoding: Set by user. @@ -562,6 +539,22 @@ typedef struct AVCodecContext { */ AVRational time_base; + /** + * Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed. + * - encoding: unused. + * - decoding: set by user. + */ + AVRational pkt_timebase; + + /** + * - decoding: For codecs that store a framerate value in the compressed + * bitstream, the decoder may export it here. { 0, 1} when + * unknown. + * - encoding: May be used to signal the framerate of CFR content to an + * encoder. + */ + AVRational framerate; + #if FF_API_TICKS_PER_FRAME /** * For some codecs, the time base is closer to the field rate than the frame rate. @@ -636,11 +629,13 @@ typedef struct AVCodecContext { int coded_width, coded_height; /** - * the number of pictures in a group of pictures, or 0 for intra_only + * sample aspect ratio (0 if unknown) + * That is the width of a pixel divided by the height of the pixel. + * Numerator and denominator must be relatively prime and smaller than 256 for some video standards. * - encoding: Set by user. - * - decoding: unused + * - decoding: Set by libavcodec. */ - int gop_size; + AVRational sample_aspect_ratio; /** * Pixel format, see AV_PIX_FMT_xxx. @@ -657,6 +652,82 @@ typedef struct AVCodecContext { */ enum AVPixelFormat pix_fmt; + /** + * Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx. + * - encoding: unused. + * - decoding: Set by libavcodec before calling get_format() + */ + enum AVPixelFormat sw_pix_fmt; + + /** + * Chromaticity coordinates of the source primaries. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorPrimaries color_primaries; + + /** + * Color Transfer Characteristic. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorTransferCharacteristic color_trc; + + /** + * YUV colorspace type. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorSpace colorspace; + + /** + * MPEG vs JPEG YUV range. + * - encoding: Set by user to override the default output color range value, + * If not specified, libavcodec sets the color range depending on the + * output format. + * - decoding: Set by libavcodec, can be set by the user to propagate the + * color range to components reading from the decoder context. + */ + enum AVColorRange color_range; + + /** + * This defines the location of chroma samples. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVChromaLocation chroma_sample_location; + + /** Field order + * - encoding: set by libavcodec + * - decoding: Set by user. + */ + enum AVFieldOrder field_order; + + /** + * number of reference frames + * - encoding: Set by user. + * - decoding: Set by lavc. + */ + int refs; + + /** + * Size of the frame reordering buffer in the decoder. + * For MPEG-2 it is 1 IPB or 0 low delay IP. + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + int has_b_frames; + + /** + * slice flags + * - encoding: unused + * - decoding: Set by user. + */ + int slice_flags; +#define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display +#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG-2 field pics) +#define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1) + /** * If non NULL, 'draw_horiz_band' is called by the libavcodec * decoder to draw a horizontal band. It improves cache usage. Not @@ -735,14 +806,6 @@ typedef struct AVCodecContext { */ float b_quant_offset; - /** - * Size of the frame reordering buffer in the decoder. - * For MPEG-2 it is 1 IPB or 0 low delay IP. - * - encoding: Set by libavcodec. - * - decoding: Set by libavcodec. - */ - int has_b_frames; - /** * qscale factor between P- and I-frames * If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset). @@ -795,13 +858,11 @@ typedef struct AVCodecContext { float dark_masking; /** - * sample aspect ratio (0 if unknown) - * That is the width of a pixel divided by the height of the pixel. - * Numerator and denominator must be relatively prime and smaller than 256 for some video standards. + * noise vs. sse weight for the nsse comparison function * - encoding: Set by user. - * - decoding: Set by libavcodec. + * - decoding: unused */ - AVRational sample_aspect_ratio; + int nsse_weight; /** * motion estimation comparison function @@ -889,16 +950,6 @@ typedef struct AVCodecContext { */ int me_range; - /** - * slice flags - * - encoding: unused - * - decoding: Set by user. - */ - int slice_flags; -#define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display -#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG-2 field pics) -#define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1) - /** * macroblock decision mode * - encoding: Set by user. @@ -927,6 +978,13 @@ typedef struct AVCodecContext { */ uint16_t *inter_matrix; + /** + * custom intra quantization matrix + * - encoding: Set by user, can be NULL. + * - decoding: unused. + */ + uint16_t *chroma_intra_matrix; + /** * precision of the intra DC coefficient - 8 * - encoding: Set by user. @@ -934,20 +992,6 @@ typedef struct AVCodecContext { */ int intra_dc_precision; - /** - * Number of macroblock rows at the top which are skipped. - * - encoding: unused - * - decoding: Set by user. - */ - int skip_top; - - /** - * Number of macroblock rows at the bottom which are skipped. - * - encoding: unused - * - decoding: Set by user. - */ - int skip_bottom; - /** * minimum MB Lagrange multiplier * - encoding: Set by user. @@ -976,11 +1020,11 @@ typedef struct AVCodecContext { int keyint_min; /** - * number of reference frames + * the number of pictures in a group of pictures, or 0 for intra_only * - encoding: Set by user. - * - decoding: Set by lavc. + * - decoding: unused */ - int refs; + int gop_size; /** * Note: Value depends upon the compare function used for fullpel ME. @@ -989,44 +1033,6 @@ typedef struct AVCodecContext { */ int mv0_threshold; - /** - * Chromaticity coordinates of the source primaries. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVColorPrimaries color_primaries; - - /** - * Color Transfer Characteristic. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVColorTransferCharacteristic color_trc; - - /** - * YUV colorspace type. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVColorSpace colorspace; - - /** - * MPEG vs JPEG YUV range. - * - encoding: Set by user to override the default output color range value, - * If not specified, libavcodec sets the color range depending on the - * output format. - * - decoding: Set by libavcodec, can be set by the user to propagate the - * color range to components reading from the decoder context. - */ - enum AVColorRange color_range; - - /** - * This defines the location of chroma samples. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVChromaLocation chroma_sample_location; - /** * Number of slices. * Indicates number of picture subdivisions. Used for parallelized @@ -1036,12 +1042,6 @@ typedef struct AVCodecContext { */ int slices; - /** Field order - * - encoding: set by libavcodec - * - decoding: Set by user. - */ - enum AVFieldOrder field_order; - /* audio only */ int sample_rate; ///< samples per second @@ -1052,6 +1052,14 @@ typedef struct AVCodecContext { */ enum AVSampleFormat sample_fmt; ///< sample format + /** + * Audio channel layout. + * - encoding: must be set by the caller, to one of AVCodec.ch_layouts. + * - decoding: may be set by the caller if known e.g. from the container. + * The decoder can then override during decoding as needed. + */ + AVChannelLayout ch_layout; + /* The following data should not be initialized. */ /** * Number of samples per channel in an audio frame. @@ -1092,6 +1100,41 @@ typedef struct AVCodecContext { */ enum AVSampleFormat request_sample_fmt; + /** + * Audio only. The number of "priming" samples (padding) inserted by the + * encoder at the beginning of the audio. I.e. this number of leading + * decoded samples must be discarded by the caller to get the original audio + * without leading padding. + * + * - decoding: unused + * - encoding: Set by libavcodec. The timestamps on the output packets are + * adjusted by the encoder so that they always refer to the + * first sample of the data actually contained in the packet, + * including any added padding. E.g. if the timebase is + * 1/samplerate and the timestamp of the first input sample is + * 0, the timestamp of the first output packet will be + * -initial_padding. + */ + int initial_padding; + + /** + * Audio only. The amount of padding (in samples) appended by the encoder to + * the end of the audio. I.e. this number of decoded samples must be + * discarded by the caller from the end of the stream to get the original + * audio without any trailing padding. + * + * - decoding: unused + * - encoding: unused + */ + int trailing_padding; + + /** + * Number of samples to skip after a discontinuity + * - decoding: unused + * - encoding: set by libavcodec + */ + int seek_preroll; + /** * This callback is called at the beginning of each frame to get data * buffer(s) for it. There may be one contiguous buffer for all the data or @@ -1175,6 +1218,29 @@ typedef struct AVCodecContext { int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags); /* - encoding parameters */ + /** + * number of bits the bitstream is allowed to diverge from the reference. + * the reference can be CBR (for CBR pass1) or VBR (for pass2) + * - encoding: Set by user; unused for constant quantizer encoding. + * - decoding: unused + */ + int bit_rate_tolerance; + + /** + * Global quality for codecs which cannot change it per frame. + * This should be proportional to MPEG-1/2/4 qscale. + * - encoding: Set by user. + * - decoding: unused + */ + int global_quality; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int compression_level; +#define FF_COMPRESSION_DEFAULT -1 + float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0) float qblur; ///< amount of qscale smoothing over time (0.0-1.0) @@ -1380,6 +1446,75 @@ typedef struct AVCodecContext { */ void *hwaccel_context; + /** + * A reference to the AVHWFramesContext describing the input (for encoding) + * or output (decoding) frames. The reference is set by the caller and + * afterwards owned (and freed) by libavcodec - it should never be read by + * the caller after being set. + * + * - decoding: This field should be set by the caller from the get_format() + * callback. The previous reference (if any) will always be + * unreffed by libavcodec before the get_format() call. + * + * If the default get_buffer2() is used with a hwaccel pixel + * format, then this AVHWFramesContext will be used for + * allocating the frame buffers. + * + * - encoding: For hardware encoders configured to use a hwaccel pixel + * format, this field should be set by the caller to a reference + * to the AVHWFramesContext describing input frames. + * AVHWFramesContext.format must be equal to + * AVCodecContext.pix_fmt. + * + * This field should be set before avcodec_open2() is called. + */ + AVBufferRef *hw_frames_ctx; + + /** + * A reference to the AVHWDeviceContext describing the device which will + * be used by a hardware encoder/decoder. The reference is set by the + * caller and afterwards owned (and freed) by libavcodec. + * + * This should be used if either the codec device does not require + * hardware frames or any that are used are to be allocated internally by + * libavcodec. If the user wishes to supply any of the frames used as + * encoder input or decoder output then hw_frames_ctx should be used + * instead. When hw_frames_ctx is set in get_format() for a decoder, this + * field will be ignored while decoding the associated stream segment, but + * may again be used on a following one after another get_format() call. + * + * For both encoders and decoders this field should be set before + * avcodec_open2() is called and must not be written to thereafter. + * + * Note that some decoders may require this field to be set initially in + * order to support hw_frames_ctx at all - in that case, all frames + * contexts used must be created on the same device. + */ + AVBufferRef *hw_device_ctx; + + /** + * Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated + * decoding (if active). + * - encoding: unused + * - decoding: Set by user (either before avcodec_open2(), or in the + * AVCodecContext.get_format callback) + */ + int hwaccel_flags; + + /* + * Video decoding only. Sets the number of extra hardware frames which + * the decoder will allocate for use by the caller. This must be set + * before avcodec_open2() is called. + * + * Some hardware decoders require all frames that they will use for + * output to be defined in advance before decoding starts. For such + * decoders, the hardware frame pool must therefore be of a fixed size. + * The extra frames set here are on top of any number that the decoder + * needs internally in order to operate normally (for example, frames + * used as reference pictures). + */ + int extra_hw_frames; + /** * error * - encoding: Set by libavcodec if flags & AV_CODEC_FLAG_PSNR. @@ -1434,13 +1569,6 @@ typedef struct AVCodecContext { */ int bits_per_raw_sample; - /** - * low resolution decoding, 1-> 1/2 size, 2->1/4 size - * - encoding: unused - * - decoding: Set by user. - */ - int lowres; - /** * thread count * is used to decide how many independent tasks should be passed to execute() @@ -1498,13 +1626,6 @@ typedef struct AVCodecContext { */ int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count); - /** - * noise vs. sse weight for the nsse comparison function - * - encoding: Set by user. - * - decoding: unused - */ - int nsse_weight; - /** * profile * - encoding: Set by user. @@ -1662,6 +1783,16 @@ typedef struct AVCodecContext { #define FF_LEVEL_UNKNOWN -99 #endif + /** + * Properties of the stream that gets decoded + * - encoding: unused + * - decoding: set by libavcodec + */ + unsigned properties; +#define FF_CODEC_PROPERTY_LOSSLESS 0x00000001 +#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002 +#define FF_CODEC_PROPERTY_FILM_GRAIN 0x00000004 + /** * Skip loop filtering for selected frames. * - encoding: unused @@ -1684,55 +1815,39 @@ typedef struct AVCodecContext { enum AVDiscard skip_frame; /** - * Header containing style information for text subtitles. - * For SUBTITLE_ASS subtitle type, it should contain the whole ASS - * [Script Info] and [V4+ Styles] section, plus the [Events] line and - * the Format line following. It shouldn't include any Dialogue line. - * - encoding: Set/allocated/freed by user (before avcodec_open2()) - * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2()) - */ - uint8_t *subtitle_header; - int subtitle_header_size; - - /** - * Audio only. The number of "priming" samples (padding) inserted by the - * encoder at the beginning of the audio. I.e. this number of leading - * decoded samples must be discarded by the caller to get the original audio - * without leading padding. + * Skip processing alpha if supported by codec. + * Note that if the format uses pre-multiplied alpha (common with VP6, + * and recommended due to better video quality/compression) + * the image will look as if alpha-blended onto a black background. + * However for formats that do not use pre-multiplied alpha + * there might be serious artefacts (though e.g. libswscale currently + * assumes pre-multiplied alpha anyway). * - * - decoding: unused - * - encoding: Set by libavcodec. The timestamps on the output packets are - * adjusted by the encoder so that they always refer to the - * first sample of the data actually contained in the packet, - * including any added padding. E.g. if the timebase is - * 1/samplerate and the timestamp of the first input sample is - * 0, the timestamp of the first output packet will be - * -initial_padding. + * - decoding: set by user + * - encoding: unused */ - int initial_padding; + int skip_alpha; /** - * - decoding: For codecs that store a framerate value in the compressed - * bitstream, the decoder may export it here. { 0, 1} when - * unknown. - * - encoding: May be used to signal the framerate of CFR content to an - * encoder. + * Number of macroblock rows at the top which are skipped. + * - encoding: unused + * - decoding: Set by user. */ - AVRational framerate; + int skip_top; /** - * Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx. - * - encoding: unused. - * - decoding: Set by libavcodec before calling get_format() + * Number of macroblock rows at the bottom which are skipped. + * - encoding: unused + * - decoding: Set by user. */ - enum AVPixelFormat sw_pix_fmt; + int skip_bottom; /** - * Timebase in which pkt_dts/pts and AVPacket.dts/pts are expressed. - * - encoding: unused. - * - decoding: set by user. + * low resolution decoding, 1-> 1/2 size, 2->1/4 size + * - encoding: unused + * - decoding: Set by user. */ - AVRational pkt_timebase; + int lowres; /** * AVCodecDescriptor @@ -1771,32 +1886,15 @@ typedef struct AVCodecContext { #define FF_SUB_CHARENC_MODE_IGNORE 2 ///< neither convert the subtitles, nor check them for valid UTF-8 /** - * Skip processing alpha if supported by codec. - * Note that if the format uses pre-multiplied alpha (common with VP6, - * and recommended due to better video quality/compression) - * the image will look as if alpha-blended onto a black background. - * However for formats that do not use pre-multiplied alpha - * there might be serious artefacts (though e.g. libswscale currently - * assumes pre-multiplied alpha anyway). - * - * - decoding: set by user - * - encoding: unused - */ - int skip_alpha; - - /** - * Number of samples to skip after a discontinuity - * - decoding: unused - * - encoding: set by libavcodec - */ - int seek_preroll; - - /** - * custom intra quantization matrix - * - encoding: Set by user, can be NULL. - * - decoding: unused. + * Header containing style information for text subtitles. + * For SUBTITLE_ASS subtitle type, it should contain the whole ASS + * [Script Info] and [V4+ Styles] section, plus the [Events] line and + * the Format line following. It shouldn't include any Dialogue line. + * - encoding: Set/allocated/freed by user (before avcodec_open2()) + * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2()) */ - uint16_t *chroma_intra_matrix; + int subtitle_header_size; + uint8_t *subtitle_header; /** * dump format separator. @@ -1814,16 +1912,6 @@ typedef struct AVCodecContext { */ char *codec_whitelist; - /** - * Properties of the stream that gets decoded - * - encoding: unused - * - decoding: set by libavcodec - */ - unsigned properties; -#define FF_CODEC_PROPERTY_LOSSLESS 0x00000001 -#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002 -#define FF_CODEC_PROPERTY_FILM_GRAIN 0x00000004 - /** * Additional data associated with the entire coded stream. * @@ -1834,39 +1922,14 @@ typedef struct AVCodecContext { int nb_coded_side_data; /** - * A reference to the AVHWFramesContext describing the input (for encoding) - * or output (decoding) frames. The reference is set by the caller and - * afterwards owned (and freed) by libavcodec - it should never be read by - * the caller after being set. - * - * - decoding: This field should be set by the caller from the get_format() - * callback. The previous reference (if any) will always be - * unreffed by libavcodec before the get_format() call. - * - * If the default get_buffer2() is used with a hwaccel pixel - * format, then this AVHWFramesContext will be used for - * allocating the frame buffers. - * - * - encoding: For hardware encoders configured to use a hwaccel pixel - * format, this field should be set by the caller to a reference - * to the AVHWFramesContext describing input frames. - * AVHWFramesContext.format must be equal to - * AVCodecContext.pix_fmt. - * - * This field should be set before avcodec_open2() is called. - */ - AVBufferRef *hw_frames_ctx; - - /** - * Audio only. The amount of padding (in samples) appended by the encoder to - * the end of the audio. I.e. this number of decoded samples must be - * discarded by the caller from the end of the stream to get the original - * audio without any trailing padding. + * Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of + * metadata exported in frame, packet, or coded stream side data by + * decoders and encoders. * - * - decoding: unused - * - encoding: unused + * - decoding: set by user + * - encoding: set by user */ - int trailing_padding; + int export_side_data; /** * The number of pixels per image to maximally accept. @@ -1876,37 +1939,6 @@ typedef struct AVCodecContext { */ int64_t max_pixels; - /** - * A reference to the AVHWDeviceContext describing the device which will - * be used by a hardware encoder/decoder. The reference is set by the - * caller and afterwards owned (and freed) by libavcodec. - * - * This should be used if either the codec device does not require - * hardware frames or any that are used are to be allocated internally by - * libavcodec. If the user wishes to supply any of the frames used as - * encoder input or decoder output then hw_frames_ctx should be used - * instead. When hw_frames_ctx is set in get_format() for a decoder, this - * field will be ignored while decoding the associated stream segment, but - * may again be used on a following one after another get_format() call. - * - * For both encoders and decoders this field should be set before - * avcodec_open2() is called and must not be written to thereafter. - * - * Note that some decoders may require this field to be set initially in - * order to support hw_frames_ctx at all - in that case, all frames - * contexts used must be created on the same device. - */ - AVBufferRef *hw_device_ctx; - - /** - * Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated - * decoding (if active). - * - encoding: unused - * - decoding: Set by user (either before avcodec_open2(), or in the - * AVCodecContext.get_format callback) - */ - int hwaccel_flags; - /** * Video decoding only. Certain video codecs support cropping, meaning that * only a sub-rectangle of the decoded frame is intended for display. This @@ -1934,20 +1966,6 @@ typedef struct AVCodecContext { */ int apply_cropping; - /* - * Video decoding only. Sets the number of extra hardware frames which - * the decoder will allocate for use by the caller. This must be set - * before avcodec_open2() is called. - * - * Some hardware decoders require all frames that they will use for - * output to be defined in advance before decoding starts. For such - * decoders, the hardware frame pool must therefore be of a fixed size. - * The extra frames set here are on top of any number that the decoder - * needs internally in order to operate normally (for example, frames - * used as reference pictures). - */ - int extra_hw_frames; - /** * The percentage of damaged samples to discard a frame. * @@ -1964,16 +1982,6 @@ typedef struct AVCodecContext { */ int64_t max_samples; - /** - * Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of - * metadata exported in frame, packet, or coded stream side data by - * decoders and encoders. - * - * - decoding: set by user - * - encoding: set by user - */ - int export_side_data; - /** * This callback is called at the beginning of each packet to get a data * buffer for it. @@ -2016,14 +2024,6 @@ typedef struct AVCodecContext { */ int (*get_encode_buffer)(struct AVCodecContext *s, AVPacket *pkt, int flags); - /** - * Audio channel layout. - * - encoding: must be set by the caller, to one of AVCodec.ch_layouts. - * - decoding: may be set by the caller if known e.g. from the container. - * The decoder can then override during decoding as needed. - */ - AVChannelLayout ch_layout; - /** * Frame counter, set by libavcodec. * @@ -2170,6 +2170,7 @@ typedef struct AVSubtitleRect { uint8_t *data[4]; int linesize[4]; + int flags; enum AVSubtitleType type; char *text; ///< 0 terminated plain UTF-8 text @@ -2180,8 +2181,6 @@ typedef struct AVSubtitleRect { * struct. */ char *ass; - - int flags; } AVSubtitleRect; typedef struct AVSubtitle {