From patchwork Thu Dec 15 18:59:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Etemesi X-Patchwork-Id: 39714 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp853468pzb; Thu, 15 Dec 2022 11:00:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf5wVpyFpcruO6mSzY7PgX3Nni0Rwo60vzQidUxR9lZmDjZN1s+3WQxR774hYwf6xHhp/uzP X-Received: by 2002:a17:906:a148:b0:7af:bc9:5e51 with SMTP id bu8-20020a170906a14800b007af0bc95e51mr25967829ejb.41.1671130826932; Thu, 15 Dec 2022 11:00:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671130826; cv=none; d=google.com; s=arc-20160816; b=rSqgyo94vR11Q7CZWMZYtY7HJ5D8wLwM8xD1Qw2ACK6pucVqkn4si8qDCvdbkdTQ7M 7Le0jHBGTHucArhZxQ/9Z49vWAWSy3nn68gi/6vXJr6ETbtGows+yqtyOuVx+iE08dHL 5H9dIg12V6BWoY2Hxs68gvMeiCZNIQY4ZlxuC3j8hWp7qTVhD6PcxTXGCyp+ja8jiyvS 8IJfkuIpnl0zQURA/tZExsA8IoARqXdTmZcbpcmtI9sLuwgTPetVGkrAtlqG0A1SBc52 nsaWXudcwqw0GnwC8kdkGUeSu/QtU2a/S2AGvosGeWsGEg0Oq8K1qepnEJ3dZmThXIG9 3Hbw== 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=B/g99QXP2nIwX2Djgrcmi2VNQmmUths1HLKz5gZ5H1Y=; b=J9RTxTpCwA/LJW5FudMpCaJUll4sRyGcANlQlqIwfVnrSAThC4fPXw1Gzax7wrA0Rf mbRJd84w+45IsXcY0ic/2plOa44BYebMdBKnQk+paRxqbN8cL4VQ8iEaMt9c3kufVfKV h0rTV5YDhYEhMWS7bepLUkBfyBjYWJ6mD8bVPOTPJkfK3Ls5Cn+g7qIGwcUJTvHai5dD 169jFI9w17TRxCr8gLDUXvkkdnJfonK3ZGi2I1WX+C9p1Oq+OxXpgGgYKRTPfIZcWcfp m6cBa2SacBr5jnmYZQPfl3K+LBESytqf0F134+WfOrupNw2zzO3mndpxz01NMBUKp/ym EpWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="Rq/1TNIz"; 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 jy11-20020a170907762b00b007ad9885d2b1si12196227ejc.301.2022.12.15.11.00.26; Thu, 15 Dec 2022 11:00: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=@gmail.com header.s=20210112 header.b="Rq/1TNIz"; 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 B02BE68BD85; Thu, 15 Dec 2022 21:00:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7B0F168BD18 for ; Thu, 15 Dec 2022 21:00:16 +0200 (EET) Received: by mail-wm1-f44.google.com with SMTP id ay2-20020a05600c1e0200b003d22e3e796dso84614wmb.0 for ; Thu, 15 Dec 2022 11:00:16 -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=QNEr6dt3sqwYLrSOzbWkct6/9aurszZL8M0aVXJrzmw=; b=Rq/1TNIzcpdixJwuKzhkusdn9nFev/FK/UPm6amCuf5oFwJq+2e1ub4z4BekXoXlzR tkxCkY/WMzp9br2YOECLVlzayXZTcD4FVyv/uWR2lFRTSN+66S8HIvV/fY4T/hlok9aK D3w3WHkxTfJ3rLb8xQxC5mmoaJ75UhSqQCp5DZ7j4L+CzAt/l8U5TN6YoJX4iezXS6DX pMJALXwu9Gr+uBJQXDnK7g+nse8z8GI788Emto53TnSrOS04Rh8ZusLLXbVRcCWN2MQP ZVjJUoj0VeZjvndrT2fEf0bEblTiNSKURQbG+c9BRA5DUbq77UH1Sk8mp8iZEwyWp98w OCbQ== 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=QNEr6dt3sqwYLrSOzbWkct6/9aurszZL8M0aVXJrzmw=; b=osebKUYK3x1p9mg3gCuJ5zDtJvpTeVtu5TzXZ3hb6AXI1J3KtSrjBzTjLzEIpfPLFg vMchdhp1RmyNL5ZRUNt1arTm+czjZGX4a9E9gVKXwNrU/swFWjYrtlLywYMxWZ0ZC46o hYgY5GlBRi5lwUbvLTkJ2NjZgoyYVXOy5dxBIcCh4TThiandhX0PaSXPyA5wuK81fhEm kenv0A2D/Q+hcJapeDtFszBdT4Ix90DS26e3jhWa7kBWyj3euitE98wcDiFBuH+vIsDm copIi5+e8YL8YrovsXmtFTHE3ZyJCSaLIeoL4ucS91T0ejJ6QQyLxKaTBYEo4G9MizyA PGQA== X-Gm-Message-State: ANoB5pnqOfyjH5ZtPZZ1cREdLdzy4E5Cgt4w+LDXKtut/gdLw3fj0G7Y VGrIylnCoeuZxokictRmDdxiSJJqW4P8HA== X-Received: by 2002:a05:600c:1e84:b0:3cf:7195:e569 with SMTP id be4-20020a05600c1e8400b003cf7195e569mr23414122wmb.40.1671130815476; Thu, 15 Dec 2022 11:00:15 -0800 (PST) Received: from localhost.localdomain ([41.80.112.89]) by smtp.gmail.com with ESMTPSA id bd26-20020a05600c1f1a00b003d070e45574sm14128wmb.11.2022.12.15.11.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 11:00:14 -0800 (PST) From: etemesicaleb@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Thu, 15 Dec 2022 21:59:59 +0300 Message-Id: <20221215185959.19191-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, git@haerdin.se Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: P0a23k0PsuSx From: caleb This should pave way for HTJ2K decoding --- 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