1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * Texture block module
3cabdff1aSopenharmony_ci * Copyright (C) 2015 Vittorio Giovara <vittorio.giovara@gmail.com>
4cabdff1aSopenharmony_ci *
5cabdff1aSopenharmony_ci * This file is part of FFmpeg.
6cabdff1aSopenharmony_ci *
7cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
8cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
9cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
10cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
11cabdff1aSopenharmony_ci *
12cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
13cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
14cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15cabdff1aSopenharmony_ci * Lesser General Public License for more details.
16cabdff1aSopenharmony_ci *
17cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
18cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
19cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20cabdff1aSopenharmony_ci */
21cabdff1aSopenharmony_ci
22cabdff1aSopenharmony_ci/**
23cabdff1aSopenharmony_ci * @file
24cabdff1aSopenharmony_ci * Texture block (4x4) module
25cabdff1aSopenharmony_ci *
26cabdff1aSopenharmony_ci * References:
27cabdff1aSopenharmony_ci *   https://www.opengl.org/wiki/S3_Texture_Compression
28cabdff1aSopenharmony_ci *   https://www.opengl.org/wiki/Red_Green_Texture_Compression
29cabdff1aSopenharmony_ci *   https://msdn.microsoft.com/en-us/library/bb694531%28v=vs.85%29.aspx
30cabdff1aSopenharmony_ci *
31cabdff1aSopenharmony_ci * All functions return how much data has been written or read.
32cabdff1aSopenharmony_ci *
33cabdff1aSopenharmony_ci * Pixel input or output format is always AV_PIX_FMT_RGBA.
34cabdff1aSopenharmony_ci */
35cabdff1aSopenharmony_ci
36cabdff1aSopenharmony_ci#ifndef AVCODEC_TEXTUREDSP_H
37cabdff1aSopenharmony_ci#define AVCODEC_TEXTUREDSP_H
38cabdff1aSopenharmony_ci
39cabdff1aSopenharmony_ci#include <stddef.h>
40cabdff1aSopenharmony_ci#include <stdint.h>
41cabdff1aSopenharmony_ci
42cabdff1aSopenharmony_ci#include "avcodec.h"
43cabdff1aSopenharmony_ci
44cabdff1aSopenharmony_ci#define TEXTURE_BLOCK_W 4
45cabdff1aSopenharmony_ci#define TEXTURE_BLOCK_H 4
46cabdff1aSopenharmony_ci
47cabdff1aSopenharmony_citypedef struct TextureDSPContext {
48cabdff1aSopenharmony_ci    int (*dxt1_block)        (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
49cabdff1aSopenharmony_ci    int (*dxt1a_block)       (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
50cabdff1aSopenharmony_ci    int (*dxt2_block)        (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
51cabdff1aSopenharmony_ci    int (*dxt3_block)        (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
52cabdff1aSopenharmony_ci    int (*dxt4_block)        (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
53cabdff1aSopenharmony_ci    int (*dxt5_block)        (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
54cabdff1aSopenharmony_ci    int (*dxt5y_block)       (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
55cabdff1aSopenharmony_ci    int (*dxt5ys_block)      (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
56cabdff1aSopenharmony_ci    int (*rgtc1s_block)      (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
57cabdff1aSopenharmony_ci    int (*rgtc1u_block)      (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
58cabdff1aSopenharmony_ci    int (*rgtc1u_gray_block) (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
59cabdff1aSopenharmony_ci    int (*rgtc1u_alpha_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
60cabdff1aSopenharmony_ci    int (*rgtc2s_block)      (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
61cabdff1aSopenharmony_ci    int (*rgtc2u_block)      (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
62cabdff1aSopenharmony_ci    int (*dxn3dc_block)      (uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
63cabdff1aSopenharmony_ci} TextureDSPContext;
64cabdff1aSopenharmony_ci
65cabdff1aSopenharmony_citypedef struct TextureDSPThreadContext {
66cabdff1aSopenharmony_ci    union {
67cabdff1aSopenharmony_ci        const uint8_t *in;       // Input frame data
68cabdff1aSopenharmony_ci        uint8_t *out;            // Output frame data
69cabdff1aSopenharmony_ci    } frame_data;
70cabdff1aSopenharmony_ci    ptrdiff_t stride;            // Frame linesize
71cabdff1aSopenharmony_ci    union {
72cabdff1aSopenharmony_ci        const uint8_t *in;       // Compressed texture for decompression
73cabdff1aSopenharmony_ci        uint8_t *out;            // Compressed texture of compression
74cabdff1aSopenharmony_ci    } tex_data;
75cabdff1aSopenharmony_ci    int tex_ratio;               // Number of compressed bytes in a texture block
76cabdff1aSopenharmony_ci    int raw_ratio;               // Number bytes in a line of a raw block
77cabdff1aSopenharmony_ci    int slice_count;             // Number of slices for threaded operations
78cabdff1aSopenharmony_ci
79cabdff1aSopenharmony_ci    /* Pointer to the selected compress or decompress function. */
80cabdff1aSopenharmony_ci    int (*tex_funct)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block);
81cabdff1aSopenharmony_ci} TextureDSPThreadContext;
82cabdff1aSopenharmony_ci
83cabdff1aSopenharmony_civoid ff_texturedsp_init(TextureDSPContext *c);
84cabdff1aSopenharmony_civoid ff_texturedspenc_init(TextureDSPContext *c);
85cabdff1aSopenharmony_ci
86cabdff1aSopenharmony_ciint ff_texturedsp_decompress_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb);
87cabdff1aSopenharmony_ciint ff_texturedsp_compress_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb);
88cabdff1aSopenharmony_ci
89cabdff1aSopenharmony_ci#endif /* AVCODEC_TEXTUREDSP_H */
90