From patchwork Sat Feb 29 12:21:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 17972 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id E472644B655 for ; Sat, 29 Feb 2020 14:23:15 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D1C4168B458; Sat, 29 Feb 2020 14:23:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-1.mx.upcmail.net (vie01a-dmta-pe06-1.mx.upcmail.net [84.116.36.14]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D9E2068AFE3 for ; Sat, 29 Feb 2020 14:23:08 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1j819A-00025y-0M for ffmpeg-devel@ffmpeg.org; Sat, 29 Feb 2020 13:23:08 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id 818Cj9Jls6Jy6818CjsSBp; Sat, 29 Feb 2020 13:22:08 +0100 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=GKl27dFK c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=bHpbcL36GbkKP7XMA2UA:9 a=D4BviALDquDo_kxh:21 a=kABuh3bK9wJXMQWo:21 a=pHzHmUro8NiASowvMSCR:22 a=Ew2E2A-JSTLzCXPT_086:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 29 Feb 2020 13:21:55 +0100 Message-Id: <20200229122156.28115-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200229122156.28115-1-michael@niedermayer.cc> References: <20200229122156.28115-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfBR3vZKXz13Hf4zcKVjn7R/E2JQZVZmrRmk/Ripg5htj9GzL0rwz/cwIojRDEDQQ6tUg5Q5viAjRv4+xU/LZUucskWH/QBIzApr8E+yzSK0m3gzMDXFu vNRaohAIhjVNCg9xwxe3FWKwJ+LXYyC2zZNrUYT/XJY/QJbpzvS4lElQ Subject: [FFmpeg-devel] [PATCH 3/4] avutil: frame Update the existing QP API 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 should extend the API to allow exporting internal tables for codecs with block sizes different from 16x16 and different values per plane or multiple values per block. This is unfinished and only to demonstrate how such API (which maintains API/ABI compatibility) would look This API may allow some codecs to export their tables with 0 copy Signed-off-by: Michael Niedermayer --- libavutil/frame.c | 21 ++++++++++++++++++++ libavutil/frame.h | 49 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 89089c6cc0..2cd680c886 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -100,6 +100,27 @@ int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type) return buf ? buf->data : NULL; } + +int av_get_qp_table_type_details(int type, int *block_size, int *independant_qps_per_block, int *dependant_qps_per_block, + int *independant_chroma_planes, int *dependant_chroma_planes, int *independant_alpha_planes, int *dependant_alpha_planes) +{ + *block_size = 16; + *independant_qps_per_block = 0; + * dependant_qps_per_block = 0; + *independant_chroma_planes = 0; + * dependant_chroma_planes = 0; + *independant_alpha_planes = 0; + * dependant_alpha_planes = 0; + switch (type) { + case 0: + case 1: + case 2: + case 3: + return 0; + default: + return AVERROR(EINVAL); + } +} #endif const char *av_get_colorspace_name(enum AVColorSpace val) diff --git a/libavutil/frame.h b/libavutil/frame.h index b966f37fe0..84ee94c7bb 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -715,12 +715,6 @@ attribute_deprecated int av_frame_get_pkt_size(const AVFrame *frame); attribute_deprecated void av_frame_set_pkt_size(AVFrame *frame, int val); -#if FF_API_FRAME_QP -attribute_deprecated -int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type); -attribute_deprecated -int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type); -#endif attribute_deprecated enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame); attribute_deprecated @@ -731,6 +725,49 @@ attribute_deprecated void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val); #endif +/** + * Get Quantization parameter table. + * This returns a 2D array of values representing the QP of the specified AVFrame. + * the array is organized in planes then rows then columns then QP per block. + * + * @param stride bytes per row in the returned array + * @returns a 2D array of QP values, the pixels per block depend on the type. + * the array is valid as long as the frame is not destroyed or a new + * qp table set. + * @see av_frame_set_qp_table() + */ +int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type); + +/** + * Set Quantization parameter table. + * This returns a 2D array of values representing the QP of the specified AVFrame. + * + * @param stride bytes per row in the set array + * @returns a 2D array of QP values, the pixels per block depend on the type. + * @see av_frame_set_qp_table() + */ +int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type); + +/** + * Returns the details, each QP represents. + * + * @param block_size spatial size of the square, each QP represents. + * @param independant_qps_per_block number of independant QP parameters per block (stored for each block) + * @param dependant_qps_per_block number of dependant QP parameters per block (stored for each plane) + * @param independant_chroma_planes number of independant planes for chroma, this can be 0, 1 or 2 + * with 0, the luma plane is used for chroma, with 1 there is + * one QP plane for both chroma components, or 2 for seperate QP + * per Chroma channel. + * @param dependant_chroma_planes number of dependant planes for chroma, for each + * dependant chroma plane a single offset parameter if stored relative to + * the previous plane + * @param independant_alpha_planes number of independant alpha planes of QP components + * @param dependant_alpha_planes number of dependant alpha planes of QP components + */ +int av_get_qp_table_type_details(int type, int *block_size, int *independant_qps_per_block, int *dependant_qps_per_block, + int *independant_chroma_planes, int *dependant_chroma_planes, int *independant_alpha_planes, int *dependant_alpha_planes); + + /** * Get the name of a colorspace. * @return a static string identifying the colorspace; can be NULL.