FFmpeg
hap.h
Go to the documentation of this file.
1 /*
2  * Vidvox Hap
3  * Copyright (C) 2015 Vittorio Giovara <vittorio.giovara@gmail.com>
4  * Copyright (C) 2015 Tom Butterworth <bangnoise@gmail.com>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef AVCODEC_HAP_H
24 #define AVCODEC_HAP_H
25 
26 #include <stdint.h>
27 
28 #include "libavutil/opt.h"
29 
30 #include "bytestream.h"
31 #include "texturedsp.h"
32 
37  HAP_FMT_RGTC1 = 0x01,
38 };
39 
41  HAP_COMP_NONE = 0xA0,
44 };
45 
51 };
52 
53 typedef struct HapChunk {
59 } HapChunk;
60 
61 typedef struct HapContext {
62  AVClass *class;
63 
66 
67  enum HapTextureFormat opt_tex_fmt; /* Texture type (encoder only) */
68  int opt_chunk_count; /* User-requested chunk count (encoder only) */
69  int opt_compressor; /* User-requested compressor (encoder only) */
70 
73  int *chunk_results; /* Results from threaded operations */
74 
75  uint8_t *tex_buf; /* Buffer for compressed texture */
76  size_t tex_size; /* Size of the compressed texture */
77 
78  size_t max_snappy; /* Maximum compressed size for snappy buffer */
79 
80  int texture_count; /* 2 for HAQA, 1 for other version */
81  int texture_section_size; /* size of the part of the texture section (for HAPQA) */
82 
85 } HapContext;
86 
87 /*
88  * Set the number of chunks in the frame. Returns 0 on success or an error if:
89  * - first_in_frame is 0 and the number of chunks has changed
90  * - any other error occurs
91  */
92 int ff_hap_set_chunk_count(HapContext *ctx, int count, int first_in_frame);
93 
94 /*
95  * Free resources associated with the context
96  */
98 
99 /* The first three bytes are the size of the section past the header, or zero
100  * if the length is stored in the next long word. The fourth byte in the first
101  * long word indicates the type of the current section. */
102 int ff_hap_parse_section_header(GetByteContext *gbc, int *section_size,
103  enum HapSectionType *section_type);
104 
105 #endif /* AVCODEC_HAP_H */
HAP_FMT_YCOCGDXT5
@ HAP_FMT_YCOCGDXT5
Definition: hap.h:36
opt.h
HapContext::opt_compressor
int opt_compressor
Definition: hap.h:69
GetByteContext
Definition: bytestream.h:33
ff_hap_parse_section_header
int ff_hap_parse_section_header(GetByteContext *gbc, int *section_size, enum HapSectionType *section_type)
Definition: hap.c:57
HapChunk::compressed_size
size_t compressed_size
Definition: hap.h:56
HapContext::tex_buf
uint8_t * tex_buf
Definition: hap.h:75
HapContext::chunks
HapChunk * chunks
Definition: hap.h:72
HapContext::enc
TextureDSPThreadContext enc
Definition: hap.h:83
TextureDSPContext
Definition: texturedsp.h:47
HapContext
Definition: hap.h:61
texturedsp.h
HAP_FMT_RGBADXT5
@ HAP_FMT_RGBADXT5
Definition: hap.h:35
HAP_COMP_SNAPPY
@ HAP_COMP_SNAPPY
Definition: hap.h:42
TextureDSPThreadContext
Definition: texturedsp.h:65
HAP_FMT_RGTC1
@ HAP_FMT_RGTC1
Definition: hap.h:37
ff_hap_free_context
av_cold void ff_hap_free_context(HapContext *ctx)
Definition: hap.c:50
HAP_COMP_NONE
@ HAP_COMP_NONE
Definition: hap.h:41
av_cold
#define av_cold
Definition: attributes.h:90
HapContext::max_snappy
size_t max_snappy
Definition: hap.h:78
HapContext::opt_chunk_count
int opt_chunk_count
Definition: hap.h:68
HAP_ST_SIZE_TABLE
@ HAP_ST_SIZE_TABLE
Definition: hap.h:49
ctx
AVFormatContext * ctx
Definition: movenc.c:48
HapContext::dxtc
TextureDSPContext dxtc
Definition: hap.h:64
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
HapContext::chunk_count
int chunk_count
Definition: hap.h:71
HAP_ST_DECODE_INSTRUCTIONS
@ HAP_ST_DECODE_INSTRUCTIONS
Definition: hap.h:47
HAP_COMP_COMPLEX
@ HAP_COMP_COMPLEX
Definition: hap.h:43
HapChunk::uncompressed_size
size_t uncompressed_size
Definition: hap.h:58
HapContext::gbc
GetByteContext gbc
Definition: hap.h:65
HapSectionType
HapSectionType
Definition: hap.h:46
HapChunk::compressor
enum HapCompressor compressor
Definition: hap.h:54
HapCompressor
HapCompressor
Definition: hap.h:40
HapTextureFormat
HapTextureFormat
Definition: hap.h:33
HAP_ST_COMPRESSOR_TABLE
@ HAP_ST_COMPRESSOR_TABLE
Definition: hap.h:48
HapChunk
Definition: hap.h:53
HapChunk::uncompressed_offset
int uncompressed_offset
Definition: hap.h:57
HapContext::texture_count
int texture_count
Definition: hap.h:80
HapContext::dec
TextureDSPThreadContext dec[2]
Definition: hap.h:84
HAP_ST_OFFSET_TABLE
@ HAP_ST_OFFSET_TABLE
Definition: hap.h:50
HAP_FMT_RGBDXT1
@ HAP_FMT_RGBDXT1
Definition: hap.h:34
HapContext::tex_size
size_t tex_size
Definition: hap.h:76
HapChunk::compressed_offset
uint32_t compressed_offset
Definition: hap.h:55
bytestream.h
HapContext::opt_tex_fmt
enum HapTextureFormat opt_tex_fmt
Definition: hap.h:67
ff_hap_set_chunk_count
int ff_hap_set_chunk_count(HapContext *ctx, int count, int first_in_frame)
Definition: hap.c:28
HapContext::texture_section_size
int texture_section_size
Definition: hap.h:81
HapContext::chunk_results
int * chunk_results
Definition: hap.h:73