From patchwork Fri Dec 2 18:10:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Etemesi X-Patchwork-Id: 39566 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp1435482pzb; Fri, 2 Dec 2022 10:11:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf5UKOlheGQvC06Pj3TCdqursALWHMKbQZeUy8Lh2JKrujxVfY0BZD2JLrVZpqAkffIsupNi X-Received: by 2002:a17:906:1b52:b0:7ad:90dc:b7d4 with SMTP id p18-20020a1709061b5200b007ad90dcb7d4mr47304944ejg.278.1670004682407; Fri, 02 Dec 2022 10:11:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670004682; cv=none; d=google.com; s=arc-20160816; b=ZKk7p6w4D+TwxstdOcGaOkuSnA6b4vOxByH5gwKo5Pbl9cI1p7jQKpw4wJa/8cSVth 7Hok1To0MrK2/RdG8SXz47DAHnARlRg+47tMVH1MKZKTGxdpcHBteEbDbuAB4Wi/jMgv vrfE0olCmD1UqK/MfiD8hNa//q/RIxGbZEI1ow0Lf6doiFNT5rboFiYek4lBXu7rAKBT G0aB6k4USsoBpTShHwtJq6ph9TVVHXlkwqyqcKcIhuEVsspJ+ncVSlK8fhU4JFJwJMDW AaQIfhFQvD+8LO2IAyGfaIZLjDZiCrZpJ+WdQPIP39yhOdD1J4nx4TCbINMnCDHQ3Ty3 E/Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=2W7zzUobAFTD1He/Af8dRtbaTtxxWXx0Mw5oR32SrvQ=; b=I1xUfolpdjmArb+BMS/0Ey7ES7ovAoc4LxANZL7GAB60uRQBedmStIio/CHO1fnpba gtsakoO4IB1l9miCUAy7ZzT2ohlNK5dD7sveN7UQyLn/O5yEmJ2uA2ZuPoOuCs7JKecW LN29QIsm5eOPJcsRHNgwFg2m7xSvmRDO07/qMZia2bmGep2Dmq5px8uNmIAAUt7ikksr 7OQSq5bKlYi47ID75s89u5qJif/LMSjhWGYsVYJ4iixWdkNICDfFNdC8jspYZfVyIOce J9xsHVJM1bYtEtRPfGQx+coZaoJa0Qx7qxOEtgyqzCi7uVJdHHmlsjpAhRFsN6FMonqn lGtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=otZJy+l8; 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 sa20-20020a1709076d1400b007c0a88076d5si5502311ejc.818.2022.12.02.10.11.19; Fri, 02 Dec 2022 10:11:22 -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=20210112 header.b=otZJy+l8; 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 3CC6C68B2F6; Fri, 2 Dec 2022 20:11:16 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B1436689F20 for ; Fri, 2 Dec 2022 20:11:09 +0200 (EET) Received: by mail-pf1-f174.google.com with SMTP id x66so5630437pfx.3 for ; Fri, 02 Dec 2022 10:11:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=CB5WjNr4pCnTgg54Aj3wOADgwFuHnyOKVyrP4nJ5EGU=; b=otZJy+l8n/BL8E8SyG26fMBrUNa5SbkN/4htsXhfXomElfU5ZCncbwle52Km2TZusF jsEG75DDHKOZvo/NsM3K6WmdPTLVeazaBgMJoigI6FKRtjKAoZeUG3FJQzGCiPvDpd1B paJP0BTJX19S4IMtn9Wq+E9YF+98+lxbY8OvFs43+2AiDLRhEaascxmD+I8zHoR9zIsW VCWjtxvqgcEr2VTqB2ePjMQLqjuPw1JR68CpcIeEB6nczCwTfvOUzvPSI8Z9iCEABZeU ifCT5d+c3LOfZnI4NeJ1ahl8bVyjtLWpp8rWUpwInUYR0iB18LerJhwUV3w3Sm848AXR mqSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CB5WjNr4pCnTgg54Aj3wOADgwFuHnyOKVyrP4nJ5EGU=; b=zvWKHGGqiZpvgg3iypljYjKnvm6GAgXlU4rhbdLrfVTYAdVCmW+wVPWgTowki5NrZu G0sDDt6ZuSUwMiLQf+0vr83n95nCmXbTpUNxWjgBFXc5H9vyk1La2RV4+7V206724/Ye sAGo5Zk28dbc1AkHI5i9zw8QEPYK936b3rRPR6Qg7+sjiIU6A/S9245w2FtvvL3uMkEX DdAerx+1ManioLXCYZkrW8q7nZbwe8Y8LT8L8e3Qy3X1YbV9BTrEyRjzKmOPAdKEGewA WY/Xd2unDbDVGEJ/HjLhOK+HOehYnFVCRsIpSV8UDTYWt+LPPFNEd7o2cYQJfzXs3v3d 5K2g== X-Gm-Message-State: ANoB5pmFiHMVAdKnXo/av3xpAouXzN1SeAKaTnpaBFo+u7GsK73ybV6j pt7SM5UjgpUaoscpezDfsqURsZhDcoLLugc/ X-Received: by 2002:a63:dd16:0:b0:476:d2d9:5151 with SMTP id t22-20020a63dd16000000b00476d2d95151mr44330572pgg.487.1670004667060; Fri, 02 Dec 2022 10:11:07 -0800 (PST) Received: from localhost.localdomain ([41.80.114.57]) by smtp.gmail.com with ESMTPSA id q13-20020a170902a3cd00b00186b04776b0sm240713plb.118.2022.12.02.10.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 10:11:06 -0800 (PST) From: etemesicaleb@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Fri, 2 Dec 2022 21:10:54 +0300 Message-Id: <20221202181054.87047-1-etemesicaleb@gmail.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Move decoder structs to header files 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: caleb , pal@sandflow.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: auPSkkp/QshY From: caleb --- libavcodec/jpeg2000dec.c | 96 +---------------------------- libavcodec/jpeg2000dec.h | 126 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+), 95 deletions(-) create mode 100644 libavcodec/jpeg2000dec.h diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index c2b81ec103..7fc09cb558 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -42,101 +42,7 @@ #include "jpeg2000.h" #include "jpeg2000dsp.h" #include "profiles.h" - -#define JP2_SIG_TYPE 0x6A502020 -#define JP2_SIG_VALUE 0x0D0A870A -#define JP2_CODESTREAM 0x6A703263 -#define JP2_HEADER 0x6A703268 - -#define HAD_COC 0x01 -#define HAD_QCC 0x02 - -#define MAX_POCS 32 - -typedef struct Jpeg2000POCEntry { - uint16_t LYEpoc; - uint16_t CSpoc; - uint16_t CEpoc; - uint8_t RSpoc; - uint8_t REpoc; - uint8_t Ppoc; -} Jpeg2000POCEntry; - -typedef struct Jpeg2000POC { - Jpeg2000POCEntry poc[MAX_POCS]; - int nb_poc; - int is_default; -} Jpeg2000POC; - -typedef struct Jpeg2000TilePart { - uint8_t tile_index; // Tile index who refers the tile-part - const uint8_t *tp_end; - GetByteContext header_tpg; // bit stream of header if PPM header is used - GetByteContext tpg; // bit stream in tile-part -} Jpeg2000TilePart; - -/* RMK: For JPEG2000 DCINEMA 3 tile-parts in a tile - * one per component, so tile_part elements have a size of 3 */ -typedef struct Jpeg2000Tile { - Jpeg2000Component *comp; - uint8_t properties[4]; - Jpeg2000CodingStyle codsty[4]; - Jpeg2000QuantStyle qntsty[4]; - Jpeg2000POC poc; - Jpeg2000TilePart tile_part[32]; - uint8_t has_ppt; // whether this tile has a ppt marker - uint8_t *packed_headers; // contains packed headers. Used only along with PPT marker - int packed_headers_size; // size in bytes of the packed headers - GetByteContext packed_headers_stream; // byte context corresponding to packed headers - uint16_t tp_idx; // Tile-part index - int coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}} -} Jpeg2000Tile; - -typedef struct Jpeg2000DecoderContext { - AVClass *class; - AVCodecContext *avctx; - GetByteContext g; - - int width, height; - int image_offset_x, image_offset_y; - int tile_offset_x, tile_offset_y; - uint8_t cbps[4]; // bits per sample in particular components - uint8_t sgnd[4]; // if a component is signed - uint8_t properties[4]; - - uint8_t has_ppm; - uint8_t *packed_headers; // contains packed headers. Used only along with PPM marker - int packed_headers_size; - GetByteContext packed_headers_stream; - uint8_t in_tile_headers; - - int cdx[4], cdy[4]; - int precision; - int ncomponents; - int colour_space; - uint32_t palette[256]; - int8_t pal8; - int cdef[4]; - int tile_width, tile_height; - unsigned numXtiles, numYtiles; - int maxtilelen; - AVRational sar; - - Jpeg2000CodingStyle codsty[4]; - Jpeg2000QuantStyle qntsty[4]; - Jpeg2000POC poc; - uint8_t roi_shift[4]; - - int bit_index; - - int curtileno; - - Jpeg2000Tile *tile; - Jpeg2000DSPContext dsp; - - /*options parameters*/ - int reduction_factor; -} Jpeg2000DecoderContext; +#include "jpeg2000dec.h" /* get_bits functions for JPEG2000 packet bitstream * It is a get_bit function with a bit-stuffing routine. If the value of the diff --git a/libavcodec/jpeg2000dec.h b/libavcodec/jpeg2000dec.h new file mode 100644 index 0000000000..b6410c1432 --- /dev/null +++ b/libavcodec/jpeg2000dec.h @@ -0,0 +1,126 @@ +/* + * JPEG 2000 image decoder + * Copyright (c) 2007 Kamil Nowosad + * Copyright (c) 2013 Nicolas Bertrand + * Copyright (c) 2022 Caleb Etemesi + * + * 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 + */ + +#ifndef AVCODEC_JPEG2000DEC_H +#define AVCODEC_JPEG2000DEC_H + +#include "bytestream.h" +#include "jpeg2000.h" +#include "jpeg2000dsp.h" + +#define JP2_SIG_TYPE 0x6A502020 +#define JP2_SIG_VALUE 0x0D0A870A +#define JP2_CODESTREAM 0x6A703263 +#define JP2_HEADER 0x6A703268 + +#define HAD_COC 0x01 +#define HAD_QCC 0x02 + +#define MAX_POCS 32 + +typedef struct Jpeg2000POCEntry { + uint16_t LYEpoc; + uint16_t CSpoc; + uint16_t CEpoc; + uint8_t RSpoc; + uint8_t REpoc; + uint8_t Ppoc; +} Jpeg2000POCEntry; + +typedef struct Jpeg2000POC { + Jpeg2000POCEntry poc[MAX_POCS]; + int nb_poc; + int is_default; +} Jpeg2000POC; + +typedef struct Jpeg2000TilePart { + uint8_t tile_index; // Tile index who refers the tile-part + const uint8_t *tp_end; + GetByteContext header_tpg; // bit stream of header if PPM header is used + GetByteContext tpg; // bit stream in tile-part +} Jpeg2000TilePart; + +/* RMK: For JPEG2000 DCINEMA 3 tile-parts in a tile + * one per component, so tile_part elements have a size of 3 */ +typedef struct Jpeg2000Tile { + Jpeg2000Component *comp; + uint8_t properties[4]; + Jpeg2000CodingStyle codsty[4]; + Jpeg2000QuantStyle qntsty[4]; + Jpeg2000POC poc; + Jpeg2000TilePart tile_part[32]; + uint8_t has_ppt; // whether this tile has a ppt marker + uint8_t *packed_headers; // contains packed headers. Used only along with PPT marker + int packed_headers_size; // size in bytes of the packed headers + GetByteContext packed_headers_stream; // byte context corresponding to packed headers + uint16_t tp_idx; // Tile-part index + int coord[2][2]; // border coordinates {{x0, x1}, {y0, y1}} +} Jpeg2000Tile; + +typedef struct Jpeg2000DecoderContext { + AVClass *class; + AVCodecContext *avctx; + GetByteContext g; + + int width, height; + int image_offset_x, image_offset_y; + int tile_offset_x, tile_offset_y; + uint8_t cbps[4]; // bits per sample in particular components + uint8_t sgnd[4]; // if a component is signed + uint8_t properties[4]; + + uint8_t has_ppm; + uint8_t *packed_headers; // contains packed headers. Used only along with PPM marker + int packed_headers_size; + GetByteContext packed_headers_stream; + uint8_t in_tile_headers; + + int cdx[4], cdy[4]; + int precision; + int ncomponents; + int colour_space; + uint32_t palette[256]; + int8_t pal8; + int cdef[4]; + int tile_width, tile_height; + unsigned numXtiles, numYtiles; + int maxtilelen; + AVRational sar; + + Jpeg2000CodingStyle codsty[4]; + Jpeg2000QuantStyle qntsty[4]; + Jpeg2000POC poc; + uint8_t roi_shift[4]; + + int bit_index; + + int curtileno; + + Jpeg2000Tile *tile; + Jpeg2000DSPContext dsp; + + /*options parameters*/ + int reduction_factor; +} Jpeg2000DecoderContext; + +#endif //AVCODEC_JPEG2000DEC_H