FFmpeg
hapenc.c
Go to the documentation of this file.
1 /*
2  * Vidvox Hap encoder
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 /**
24  * @file
25  * Hap encoder
26  *
27  * Fourcc: Hap1, Hap5, HapY
28  *
29  * https://github.com/Vidvox/hap/blob/master/documentation/HapVideoDRAFT.md
30  */
31 
32 #include <stdint.h>
33 #include "snappy-c.h"
34 
35 #include "libavutil/frame.h"
36 #include "libavutil/imgutils.h"
37 #include "libavutil/intreadwrite.h"
38 #include "libavutil/opt.h"
39 
40 #include "avcodec.h"
41 #include "bytestream.h"
42 #include "encode.h"
43 #include "hap.h"
44 #include "internal.h"
45 #include "texturedsp.h"
46 
47 #define HAP_MAX_CHUNKS 64
48 
50  /* Short header: four bytes with a 24 bit size value */
52  /* Long header: eight bytes with a 32 bit size value */
54 };
55 
56 static int compress_texture(AVCodecContext *avctx, uint8_t *out, int out_length, const AVFrame *f)
57 {
58  HapContext *ctx = avctx->priv_data;
59  int i, j;
60 
61  if (ctx->tex_size > out_length)
63 
64  for (j = 0; j < avctx->height; j += 4) {
65  for (i = 0; i < avctx->width; i += 4) {
66  uint8_t *p = f->data[0] + i * 4 + j * f->linesize[0];
67  const int step = ctx->tex_fun(out, f->linesize[0], p);
68  out += step;
69  }
70  }
71 
72  return 0;
73 }
74 
75 /* section_length does not include the header */
77  enum HapHeaderLength header_length,
78  int section_length,
79  enum HapSectionType section_type)
80 {
81  /* The first three bytes are the length of the section (not including the
82  * header) or zero if using an eight-byte header.
83  * For an eight-byte header, the length is in the last four bytes.
84  * The fourth byte stores the section type. */
85  bytestream2_put_le24(pbc, header_length == HAP_HDR_LONG ? 0 : section_length);
86  bytestream2_put_byte(pbc, section_type);
87 
88  if (header_length == HAP_HDR_LONG) {
89  bytestream2_put_le32(pbc, section_length);
90  }
91 }
92 
93 static int hap_compress_frame(AVCodecContext *avctx, uint8_t *dst)
94 {
95  HapContext *ctx = avctx->priv_data;
96  int i, final_size = 0;
97 
98  for (i = 0; i < ctx->chunk_count; i++) {
99  HapChunk *chunk = &ctx->chunks[i];
100  uint8_t *chunk_src, *chunk_dst;
101  int ret;
102 
103  if (i == 0) {
104  chunk->compressed_offset = 0;
105  } else {
106  chunk->compressed_offset = ctx->chunks[i-1].compressed_offset
107  + ctx->chunks[i-1].compressed_size;
108  }
109  chunk->uncompressed_size = ctx->tex_size / ctx->chunk_count;
110  chunk->uncompressed_offset = i * chunk->uncompressed_size;
111  chunk->compressed_size = ctx->max_snappy;
112  chunk_src = ctx->tex_buf + chunk->uncompressed_offset;
113  chunk_dst = dst + chunk->compressed_offset;
114 
115  /* Compress with snappy too, write directly on packet buffer. */
116  ret = snappy_compress(chunk_src, chunk->uncompressed_size,
117  chunk_dst, &chunk->compressed_size);
118  if (ret != SNAPPY_OK) {
119  av_log(avctx, AV_LOG_ERROR, "Snappy compress error.\n");
120  return AVERROR_BUG;
121  }
122 
123  /* If there is no gain from snappy, just use the raw texture. */
124  if (chunk->compressed_size >= chunk->uncompressed_size) {
125  av_log(avctx, AV_LOG_VERBOSE,
126  "Snappy buffer bigger than uncompressed (%"SIZE_SPECIFIER" >= %"SIZE_SPECIFIER" bytes).\n",
127  chunk->compressed_size, chunk->uncompressed_size);
128  memcpy(chunk_dst, chunk_src, chunk->uncompressed_size);
129  chunk->compressor = HAP_COMP_NONE;
130  chunk->compressed_size = chunk->uncompressed_size;
131  } else {
132  chunk->compressor = HAP_COMP_SNAPPY;
133  }
134 
135  final_size += chunk->compressed_size;
136  }
137 
138  return final_size;
139 }
140 
142 {
143  /* Second-Stage Compressor Table (one byte per entry)
144  * + Chunk Size Table (four bytes per entry)
145  * + headers for both sections (short versions)
146  * = chunk_count + (4 * chunk_count) + 4 + 4 */
147  return (5 * ctx->chunk_count) + 8;
148 }
149 
151 {
152  /* Top section header (long version) */
153  int length = HAP_HDR_LONG;
154 
155  if (ctx->chunk_count > 1) {
156  /* Decode Instructions header (short) + Decode Instructions Container */
158  }
159 
160  return length;
161 }
162 
163 static void hap_write_frame_header(HapContext *ctx, uint8_t *dst, int frame_length)
164 {
165  PutByteContext pbc;
166  int i;
167 
168  bytestream2_init_writer(&pbc, dst, frame_length);
169  if (ctx->chunk_count == 1) {
170  /* Write a simple header */
171  hap_write_section_header(&pbc, HAP_HDR_LONG, frame_length - 8,
172  ctx->chunks[0].compressor | ctx->opt_tex_fmt);
173  } else {
174  /* Write a complex header with Decode Instructions Container */
175  hap_write_section_header(&pbc, HAP_HDR_LONG, frame_length - 8,
176  HAP_COMP_COMPLEX | ctx->opt_tex_fmt);
179  hap_write_section_header(&pbc, HAP_HDR_SHORT, ctx->chunk_count,
181 
182  for (i = 0; i < ctx->chunk_count; i++) {
183  bytestream2_put_byte(&pbc, ctx->chunks[i].compressor >> 4);
184  }
185 
186  hap_write_section_header(&pbc, HAP_HDR_SHORT, ctx->chunk_count * 4,
188 
189  for (i = 0; i < ctx->chunk_count; i++) {
190  bytestream2_put_le32(&pbc, ctx->chunks[i].compressed_size);
191  }
192  }
193 }
194 
195 static int hap_encode(AVCodecContext *avctx, AVPacket *pkt,
196  const AVFrame *frame, int *got_packet)
197 {
198  HapContext *ctx = avctx->priv_data;
199  int header_length = hap_header_length(ctx);
200  int final_data_size, ret;
201  int pktsize = FFMAX(ctx->tex_size, ctx->max_snappy * ctx->chunk_count) + header_length;
202 
203  /* Allocate maximum size packet, shrink later. */
204  ret = ff_alloc_packet(avctx, pkt, pktsize);
205  if (ret < 0)
206  return ret;
207 
208  if (ctx->opt_compressor == HAP_COMP_NONE) {
209  /* DXTC compression directly to the packet buffer. */
210  ret = compress_texture(avctx, pkt->data + header_length, pkt->size - header_length, frame);
211  if (ret < 0)
212  return ret;
213 
214  ctx->chunks[0].compressor = HAP_COMP_NONE;
215  final_data_size = ctx->tex_size;
216  } else {
217  /* DXTC compression. */
218  ret = compress_texture(avctx, ctx->tex_buf, ctx->tex_size, frame);
219  if (ret < 0)
220  return ret;
221 
222  /* Compress (using Snappy) the frame */
223  final_data_size = hap_compress_frame(avctx, pkt->data + header_length);
224  if (final_data_size < 0)
225  return final_data_size;
226  }
227 
228  /* Write header at the start. */
229  hap_write_frame_header(ctx, pkt->data, final_data_size + header_length);
230 
231  av_shrink_packet(pkt, final_data_size + header_length);
232  *got_packet = 1;
233  return 0;
234 }
235 
236 static av_cold int hap_init(AVCodecContext *avctx)
237 {
238  HapContext *ctx = avctx->priv_data;
239  int ratio;
240  int corrected_chunk_count;
241  int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
242 
243  if (ret < 0) {
244  av_log(avctx, AV_LOG_ERROR, "Invalid video size %dx%d.\n",
245  avctx->width, avctx->height);
246  return ret;
247  }
248 
249  if (avctx->width % 4 || avctx->height % 4) {
250  av_log(avctx, AV_LOG_ERROR, "Video size %dx%d is not multiple of 4.\n",
251  avctx->width, avctx->height);
252  return AVERROR_INVALIDDATA;
253  }
254 
255  ff_texturedspenc_init(&ctx->dxtc);
256 
257  switch (ctx->opt_tex_fmt) {
258  case HAP_FMT_RGBDXT1:
259  ratio = 8;
260  avctx->codec_tag = MKTAG('H', 'a', 'p', '1');
261  avctx->bits_per_coded_sample = 24;
262  ctx->tex_fun = ctx->dxtc.dxt1_block;
263  break;
264  case HAP_FMT_RGBADXT5:
265  ratio = 4;
266  avctx->codec_tag = MKTAG('H', 'a', 'p', '5');
267  avctx->bits_per_coded_sample = 32;
268  ctx->tex_fun = ctx->dxtc.dxt5_block;
269  break;
270  case HAP_FMT_YCOCGDXT5:
271  ratio = 4;
272  avctx->codec_tag = MKTAG('H', 'a', 'p', 'Y');
273  avctx->bits_per_coded_sample = 24;
274  ctx->tex_fun = ctx->dxtc.dxt5ys_block;
275  break;
276  default:
277  av_log(avctx, AV_LOG_ERROR, "Invalid format %02X\n", ctx->opt_tex_fmt);
278  return AVERROR_INVALIDDATA;
279  }
280 
281  /* Texture compression ratio is constant, so can we computer
282  * beforehand the final size of the uncompressed buffer. */
283  ctx->tex_size = FFALIGN(avctx->width, TEXTURE_BLOCK_W) *
284  FFALIGN(avctx->height, TEXTURE_BLOCK_H) * 4 / ratio;
285 
286  switch (ctx->opt_compressor) {
287  case HAP_COMP_NONE:
288  /* No benefit chunking uncompressed data */
289  corrected_chunk_count = 1;
290 
291  ctx->max_snappy = ctx->tex_size;
292  ctx->tex_buf = NULL;
293  break;
294  case HAP_COMP_SNAPPY:
295  /* Round the chunk count to divide evenly on DXT block edges */
296  corrected_chunk_count = av_clip(ctx->opt_chunk_count, 1, HAP_MAX_CHUNKS);
297  while ((ctx->tex_size / (64 / ratio)) % corrected_chunk_count != 0) {
298  corrected_chunk_count--;
299  }
300 
301  ctx->max_snappy = snappy_max_compressed_length(ctx->tex_size / corrected_chunk_count);
302  ctx->tex_buf = av_malloc(ctx->tex_size);
303  if (!ctx->tex_buf) {
304  return AVERROR(ENOMEM);
305  }
306  break;
307  default:
308  av_log(avctx, AV_LOG_ERROR, "Invalid compresor %02X\n", ctx->opt_compressor);
309  return AVERROR_INVALIDDATA;
310  }
311  if (corrected_chunk_count != ctx->opt_chunk_count) {
312  av_log(avctx, AV_LOG_INFO, "%d chunks requested but %d used.\n",
313  ctx->opt_chunk_count, corrected_chunk_count);
314  }
315  ret = ff_hap_set_chunk_count(ctx, corrected_chunk_count, 1);
316  if (ret != 0)
317  return ret;
318 
319  return 0;
320 }
321 
322 static av_cold int hap_close(AVCodecContext *avctx)
323 {
324  HapContext *ctx = avctx->priv_data;
325 
327 
328  return 0;
329 }
330 
331 #define OFFSET(x) offsetof(HapContext, x)
332 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
333 static const AVOption options[] = {
334  { "format", NULL, OFFSET(opt_tex_fmt), AV_OPT_TYPE_INT, { .i64 = HAP_FMT_RGBDXT1 }, HAP_FMT_RGBDXT1, HAP_FMT_YCOCGDXT5, FLAGS, "format" },
335  { "hap", "Hap 1 (DXT1 textures)", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_FMT_RGBDXT1 }, 0, 0, FLAGS, "format" },
336  { "hap_alpha", "Hap Alpha (DXT5 textures)", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_FMT_RGBADXT5 }, 0, 0, FLAGS, "format" },
337  { "hap_q", "Hap Q (DXT5-YCoCg textures)", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_FMT_YCOCGDXT5 }, 0, 0, FLAGS, "format" },
338  { "chunks", "chunk count", OFFSET(opt_chunk_count), AV_OPT_TYPE_INT, {.i64 = 1 }, 1, HAP_MAX_CHUNKS, FLAGS, },
339  { "compressor", "second-stage compressor", OFFSET(opt_compressor), AV_OPT_TYPE_INT, { .i64 = HAP_COMP_SNAPPY }, HAP_COMP_NONE, HAP_COMP_SNAPPY, FLAGS, "compressor" },
340  { "none", "None", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_COMP_NONE }, 0, 0, FLAGS, "compressor" },
341  { "snappy", "Snappy", 0, AV_OPT_TYPE_CONST, { .i64 = HAP_COMP_SNAPPY }, 0, 0, FLAGS, "compressor" },
342  { NULL },
343 };
344 
345 static const AVClass hapenc_class = {
346  .class_name = "Hap encoder",
347  .item_name = av_default_item_name,
348  .option = options,
349  .version = LIBAVUTIL_VERSION_INT,
350 };
351 
353  .name = "hap",
354  .long_name = NULL_IF_CONFIG_SMALL("Vidvox Hap"),
355  .type = AVMEDIA_TYPE_VIDEO,
356  .id = AV_CODEC_ID_HAP,
357  .priv_data_size = sizeof(HapContext),
358  .priv_class = &hapenc_class,
359  .init = hap_init,
360  .encode2 = hap_encode,
361  .close = hap_close,
362  .pix_fmts = (const enum AVPixelFormat[]) {
364  },
365  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
367 };
AVCodec
AVCodec.
Definition: codec.h:202
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:42
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
HAP_FMT_YCOCGDXT5
@ HAP_FMT_YCOCGDXT5
Definition: hap.h:36
av_clip
#define av_clip
Definition: common.h:96
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
TEXTURE_BLOCK_H
#define TEXTURE_BLOCK_H
Definition: texturedsp.h:43
out
FILE * out
Definition: movenc.c:54
OFFSET
#define OFFSET(x)
Definition: hapenc.c:331
HapChunk::compressed_size
size_t compressed_size
Definition: hap.h:56
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:373
AVOption
AVOption.
Definition: opt.h:247
encode.h
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
hap_compress_frame
static int hap_compress_frame(AVCodecContext *avctx, uint8_t *dst)
Definition: hapenc.c:93
HapContext
Definition: hap.h:61
hapenc_class
static const AVClass hapenc_class
Definition: hapenc.c:345
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
HapHeaderLength
HapHeaderLength
Definition: hapenc.c:49
init
static int init
Definition: av_tx.c:47
hap_init
static av_cold int hap_init(AVCodecContext *avctx)
Definition: hapenc.c:236
texturedsp.h
hap.h
av_shrink_packet
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:114
AVERROR_BUFFER_TOO_SMALL
#define AVERROR_BUFFER_TOO_SMALL
Buffer too small.
Definition: error.h:53
hap_close
static av_cold int hap_close(AVCodecContext *avctx)
Definition: hapenc.c:322
HAP_FMT_RGBADXT5
@ HAP_FMT_RGBADXT5
Definition: hap.h:35
HAP_COMP_SNAPPY
@ HAP_COMP_SNAPPY
Definition: hap.h:42
HAP_COMP_NONE
@ HAP_COMP_NONE
Definition: hap.h:41
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
hap_write_section_header
static void hap_write_section_header(PutByteContext *pbc, enum HapHeaderLength header_length, int section_length, enum HapSectionType section_type)
Definition: hapenc.c:76
bytestream2_init_writer
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
Definition: bytestream.h:147
intreadwrite.h
ff_hap_free_context
av_cold void ff_hap_free_context(HapContext *ctx)
Definition: hap.c:50
HAP_ST_SIZE_TABLE
@ HAP_ST_SIZE_TABLE
Definition: hap.h:49
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
ctx
AVFormatContext * ctx
Definition: movenc.c:48
ff_texturedspenc_init
void ff_texturedspenc_init(TextureDSPContext *c)
Definition: texturedspenc.c:666
f
#define f(width, name)
Definition: cbs_vp9.c:255
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
HAP_HDR_SHORT
@ HAP_HDR_SHORT
Definition: hapenc.c:51
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
ff_hap_encoder
const AVCodec ff_hap_encoder
Definition: hapenc.c:352
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
HAP_ST_DECODE_INSTRUCTIONS
@ HAP_ST_DECODE_INSTRUCTIONS
Definition: hap.h:47
options
static const AVOption options[]
Definition: hapenc.c:333
HAP_COMP_COMPLEX
@ HAP_COMP_COMPLEX
Definition: hap.h:43
ff_hap_set_chunk_count
int ff_hap_set_chunk_count(HapContext *ctx, int count, int first_in_frame)
Definition: hap.c:28
HapChunk::uncompressed_size
size_t uncompressed_size
Definition: hap.h:58
PutByteContext
Definition: bytestream.h:37
HapSectionType
HapSectionType
Definition: hap.h:46
AVPacket::size
int size
Definition: packet.h:374
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
HapChunk::compressor
enum HapCompressor compressor
Definition: hap.h:54
hap_write_frame_header
static void hap_write_frame_header(HapContext *ctx, uint8_t *dst, int frame_length)
Definition: hapenc.c:163
frame.h
FLAGS
#define FLAGS
Definition: hapenc.c:332
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
AVCodecContext::bits_per_coded_sample
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1418
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
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:50
TEXTURE_BLOCK_W
#define TEXTURE_BLOCK_W
Definition: texturedsp.h:42
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:209
AVCodecContext::height
int height
Definition: avcodec.h:556
avcodec.h
ret
ret
Definition: filter_design.txt:187
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
hap_encode
static int hap_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: hapenc.c:195
HAP_MAX_CHUNKS
#define HAP_MAX_CHUNKS
Definition: hapenc.c:47
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:193
AVCodecContext
main external API structure.
Definition: avcodec.h:383
AV_CODEC_ID_HAP
@ AV_CODEC_ID_HAP
Definition: codec_id.h:239
hap_decode_instructions_length
static int hap_decode_instructions_length(HapContext *ctx)
Definition: hapenc.c:141
HAP_FMT_RGBDXT1
@ HAP_FMT_RGBDXT1
Definition: hap.h:34
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
HAP_HDR_LONG
@ HAP_HDR_LONG
Definition: hapenc.c:53
AVCodecContext::codec_tag
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:408
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AVPacket
This structure stores compressed data.
Definition: packet.h:350
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:410
HapChunk::compressed_offset
uint32_t compressed_offset
Definition: hap.h:55
hap_header_length
static int hap_header_length(HapContext *ctx)
Definition: hapenc.c:150
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:556
bytestream.h
imgutils.h
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
av_image_check_size
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
Definition: imgutils.c:318
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
ff_alloc_packet
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
Definition: encode.c:34
compress_texture
static int compress_texture(AVCodecContext *avctx, uint8_t *out, int out_length, const AVFrame *f)
Definition: hapenc.c:56