FFmpeg  4.4.9
hapdec.c
Go to the documentation of this file.
1 /*
2  * Vidvox Hap decoder
3  * Copyright (C) 2015 Vittorio Giovara <vittorio.giovara@gmail.com>
4  * Copyright (C) 2015 Tom Butterworth <bangnoise@gmail.com>
5  *
6  * HapQA and HAPAlphaOnly added by Jokyo Images
7  *
8  * This file is part of FFmpeg.
9  *
10  * FFmpeg is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * FFmpeg is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with FFmpeg; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  */
24 
25 /**
26  * @file
27  * Hap decoder
28  *
29  * Fourcc: Hap1, Hap5, HapY, HapA, HapM
30  *
31  * https://github.com/Vidvox/hap/blob/master/documentation/HapVideoDRAFT.md
32  */
33 
34 #include <stdint.h>
35 
36 #include "libavutil/imgutils.h"
37 
38 #include "avcodec.h"
39 #include "bytestream.h"
40 #include "hap.h"
41 #include "internal.h"
42 #include "snappy.h"
43 #include "texturedsp.h"
44 #include "thread.h"
45 
47 {
48  GetByteContext *gbc = &ctx->gbc;
49  int section_size;
50  enum HapSectionType section_type;
51  int is_first_table = 1, had_offsets = 0, had_compressors = 0, had_sizes = 0;
52  int i, ret;
53 
54  while (size > 0) {
55  int stream_remaining = bytestream2_get_bytes_left(gbc);
56  ret = ff_hap_parse_section_header(gbc, &section_size, &section_type);
57  if (ret != 0)
58  return ret;
59 
60  size -= stream_remaining - bytestream2_get_bytes_left(gbc);
61 
62  switch (section_type) {
64  ret = ff_hap_set_chunk_count(ctx, section_size, is_first_table);
65  if (ret != 0)
66  return ret;
67  for (i = 0; i < section_size; i++) {
68  ctx->chunks[i].compressor = bytestream2_get_byte(gbc) << 4;
69  }
70  had_compressors = 1;
71  is_first_table = 0;
72  break;
73  case HAP_ST_SIZE_TABLE:
74  ret = ff_hap_set_chunk_count(ctx, section_size / 4, is_first_table);
75  if (ret != 0)
76  return ret;
77  for (i = 0; i < section_size / 4; i++) {
78  ctx->chunks[i].compressed_size = bytestream2_get_le32(gbc);
79  }
80  had_sizes = 1;
81  is_first_table = 0;
82  break;
84  ret = ff_hap_set_chunk_count(ctx, section_size / 4, is_first_table);
85  if (ret != 0)
86  return ret;
87  for (i = 0; i < section_size / 4; i++) {
88  ctx->chunks[i].compressed_offset = bytestream2_get_le32(gbc);
89  }
90  had_offsets = 1;
91  is_first_table = 0;
92  break;
93  default:
94  break;
95  }
96  size -= section_size;
97  }
98 
99  if (!had_sizes || !had_compressors)
100  return AVERROR_INVALIDDATA;
101 
102  /* The offsets table is optional. If not present than calculate offsets by
103  * summing the sizes of preceding chunks. */
104  if (!had_offsets) {
105  size_t running_size = 0;
106  for (i = 0; i < ctx->chunk_count; i++) {
107  ctx->chunks[i].compressed_offset = running_size;
108  if (ctx->chunks[i].compressed_size > UINT32_MAX - running_size)
109  return AVERROR_INVALIDDATA;
110  running_size += ctx->chunks[i].compressed_size;
111  }
112  }
113 
114  return 0;
115 }
116 
118 {
119  int i;
120  size_t running_offset = 0;
121  for (i = 0; i < ctx->chunk_count; i++) {
122  if (ctx->chunks[i].compressed_offset != running_offset
123  || ctx->chunks[i].compressor != HAP_COMP_NONE)
124  return 0;
125  running_offset += ctx->chunks[i].compressed_size;
126  }
127  return 1;
128 }
129 
131 {
132  HapContext *ctx = avctx->priv_data;
133  GetByteContext *gbc = &ctx->gbc;
134  int section_size;
135  enum HapSectionType section_type;
136  const char *compressorstr;
137  int i, ret;
138 
139  ret = ff_hap_parse_section_header(gbc, &ctx->texture_section_size, &section_type);
140  if (ret != 0)
141  return ret;
142 
143  if ((avctx->codec_tag == MKTAG('H','a','p','1') && (section_type & 0x0F) != HAP_FMT_RGBDXT1) ||
144  (avctx->codec_tag == MKTAG('H','a','p','5') && (section_type & 0x0F) != HAP_FMT_RGBADXT5) ||
145  (avctx->codec_tag == MKTAG('H','a','p','Y') && (section_type & 0x0F) != HAP_FMT_YCOCGDXT5) ||
146  (avctx->codec_tag == MKTAG('H','a','p','A') && (section_type & 0x0F) != HAP_FMT_RGTC1) ||
147  ((avctx->codec_tag == MKTAG('H','a','p','M') && (section_type & 0x0F) != HAP_FMT_RGTC1) &&
148  (section_type & 0x0F) != HAP_FMT_YCOCGDXT5)) {
149  av_log(avctx, AV_LOG_ERROR,
150  "Invalid texture format %#04x.\n", section_type & 0x0F);
151  return AVERROR_INVALIDDATA;
152  }
153 
154  switch (section_type & 0xF0) {
155  case HAP_COMP_NONE:
156  case HAP_COMP_SNAPPY:
157  ret = ff_hap_set_chunk_count(ctx, 1, 1);
158  if (ret == 0) {
159  ctx->chunks[0].compressor = section_type & 0xF0;
160  ctx->chunks[0].compressed_offset = 0;
161  ctx->chunks[0].compressed_size = ctx->texture_section_size;
162  }
163  if (ctx->chunks[0].compressor == HAP_COMP_NONE) {
164  compressorstr = "none";
165  } else {
166  compressorstr = "snappy";
167  }
168  break;
169  case HAP_COMP_COMPLEX:
170  ret = ff_hap_parse_section_header(gbc, &section_size, &section_type);
171  if (ret == 0 && section_type != HAP_ST_DECODE_INSTRUCTIONS)
172  ret = AVERROR_INVALIDDATA;
173  if (ret == 0)
174  ret = hap_parse_decode_instructions(ctx, section_size);
175  compressorstr = "complex";
176  break;
177  default:
178  ret = AVERROR_INVALIDDATA;
179  break;
180  }
181 
182  if (ret != 0)
183  return ret;
184 
185  /* Check the frame is valid and read the uncompressed chunk sizes */
186  ctx->tex_size = 0;
187  for (i = 0; i < ctx->chunk_count; i++) {
188  HapChunk *chunk = &ctx->chunks[i];
189  int64_t uncompressed_size;
190 
191  /* Check the compressed buffer is valid */
192  if (chunk->compressed_offset + (uint64_t)chunk->compressed_size > bytestream2_get_bytes_left(gbc))
193  return AVERROR_INVALIDDATA;
194 
195  /* Chunks are unpacked sequentially, ctx->tex_size is the uncompressed
196  * size thus far */
197  chunk->uncompressed_offset = ctx->tex_size;
198 
199  /* Fill out uncompressed size */
200  if (chunk->compressor == HAP_COMP_SNAPPY) {
201  GetByteContext gbc_tmp;
202  bytestream2_init(&gbc_tmp, gbc->buffer + chunk->compressed_offset,
203  chunk->compressed_size);
204  uncompressed_size = ff_snappy_peek_uncompressed_length(&gbc_tmp);
205  if (uncompressed_size < 0) {
206  return uncompressed_size;
207  }
208  } else if (chunk->compressor == HAP_COMP_NONE) {
209  uncompressed_size = chunk->compressed_size;
210  } else {
211  return AVERROR_INVALIDDATA;
212  }
213  if (uncompressed_size > INT_MAX - ctx->tex_size)
214  return AVERROR_INVALIDDATA;
215  chunk->uncompressed_size = uncompressed_size;
216  ctx->tex_size += uncompressed_size;
217  }
218 
219  av_log(avctx, AV_LOG_DEBUG, "%s compressor\n", compressorstr);
220 
221  return ret;
222 }
223 
224 static int decompress_chunks_thread(AVCodecContext *avctx, void *arg,
225  int chunk_nb, int thread_nb)
226 {
227  HapContext *ctx = avctx->priv_data;
228 
229  HapChunk *chunk = &ctx->chunks[chunk_nb];
230  GetByteContext gbc;
231  uint8_t *dst = ctx->tex_buf + chunk->uncompressed_offset;
232 
233  bytestream2_init(&gbc, ctx->gbc.buffer + chunk->compressed_offset, chunk->compressed_size);
234 
235  if (chunk->compressor == HAP_COMP_SNAPPY) {
236  int ret;
237  int64_t uncompressed_size = ctx->tex_size;
238 
239  /* Uncompress the frame */
240  ret = ff_snappy_uncompress(&gbc, dst, &uncompressed_size);
241  if (ret < 0) {
242  av_log(avctx, AV_LOG_ERROR, "Snappy uncompress error\n");
243  return ret;
244  }
245  } else if (chunk->compressor == HAP_COMP_NONE) {
246  bytestream2_get_buffer(&gbc, dst, chunk->compressed_size);
247  }
248 
249  return 0;
250 }
251 
253  int slice, int thread_nb, int texture_num)
254 {
255  HapContext *ctx = avctx->priv_data;
256  AVFrame *frame = arg;
257  const uint8_t *d = ctx->tex_data;
258  int w_block = avctx->coded_width / TEXTURE_BLOCK_W;
259  int h_block = avctx->coded_height / TEXTURE_BLOCK_H;
260  int x, y;
261  int start_slice, end_slice;
262  int base_blocks_per_slice = h_block / ctx->slice_count;
263  int remainder_blocks = h_block % ctx->slice_count;
264 
265  /* When the frame height (in blocks) doesn't divide evenly between the
266  * number of slices, spread the remaining blocks evenly between the first
267  * operations */
268  start_slice = slice * base_blocks_per_slice;
269  /* Add any extra blocks (one per slice) that have been added before this slice */
270  start_slice += FFMIN(slice, remainder_blocks);
271 
272  end_slice = start_slice + base_blocks_per_slice;
273  /* Add an extra block if there are still remainder blocks to be accounted for */
274  if (slice < remainder_blocks)
275  end_slice++;
276 
277  for (y = start_slice; y < end_slice; y++) {
278  uint8_t *p = frame->data[0] + y * frame->linesize[0] * TEXTURE_BLOCK_H;
279  int off = y * w_block;
280  for (x = 0; x < w_block; x++) {
281  if (texture_num == 0) {
282  ctx->tex_fun(p + x * 4 * ctx->uncompress_pix_size, frame->linesize[0],
283  d + (off + x) * ctx->tex_rat);
284  } else {
285  ctx->tex_fun2(p + x * 4 * ctx->uncompress_pix_size, frame->linesize[0],
286  d + (off + x) * ctx->tex_rat2);
287  }
288  }
289  }
290 
291  return 0;
292 }
293 
295  int slice, int thread_nb)
296 {
297  return decompress_texture_thread_internal(avctx, arg, slice, thread_nb, 0);
298 }
299 
301  int slice, int thread_nb)
302 {
303  return decompress_texture_thread_internal(avctx, arg, slice, thread_nb, 1);
304 }
305 
306 static int hap_decode(AVCodecContext *avctx, void *data,
307  int *got_frame, AVPacket *avpkt)
308 {
309  HapContext *ctx = avctx->priv_data;
310  ThreadFrame tframe;
311  int ret, i, t;
312  int section_size;
313  enum HapSectionType section_type;
314  int start_texture_section = 0;
315  int tex_rat[2] = {0, 0};
316 
317  bytestream2_init(&ctx->gbc, avpkt->data, avpkt->size);
318 
319  tex_rat[0] = ctx->tex_rat;
320 
321  /* check for multi texture header */
322  if (ctx->texture_count == 2) {
323  ret = ff_hap_parse_section_header(&ctx->gbc, &section_size, &section_type);
324  if (ret != 0)
325  return ret;
326  if ((section_type & 0x0F) != 0x0D) {
327  av_log(avctx, AV_LOG_ERROR, "Invalid section type in 2 textures mode %#04x.\n", section_type);
328  return AVERROR_INVALIDDATA;
329  }
330  start_texture_section = 4;
331  tex_rat[1] = ctx->tex_rat2;
332  }
333 
334  /* Get the output frame ready to receive data */
335  tframe.f = data;
336  ret = ff_thread_get_buffer(avctx, &tframe, 0);
337  if (ret < 0)
338  return ret;
339 
340  for (t = 0; t < ctx->texture_count; t++) {
341  bytestream2_seek(&ctx->gbc, start_texture_section, SEEK_SET);
342 
343  /* Check for section header */
344  ret = hap_parse_frame_header(avctx);
345  if (ret < 0)
346  return ret;
347 
348  if (ctx->tex_size != (avctx->coded_width / TEXTURE_BLOCK_W)
349  *(avctx->coded_height / TEXTURE_BLOCK_H)
350  *tex_rat[t]) {
351  av_log(avctx, AV_LOG_ERROR, "uncompressed size mismatches\n");
352  return AVERROR_INVALIDDATA;
353  }
354 
355  start_texture_section += ctx->texture_section_size + 4;
356 
357  if (avctx->codec->update_thread_context)
358  ff_thread_finish_setup(avctx);
359 
360  /* Unpack the DXT texture */
362  int tex_size;
363  /* Only DXTC texture compression in a contiguous block */
364  ctx->tex_data = ctx->gbc.buffer;
365  tex_size = FFMIN(ctx->texture_section_size, bytestream2_get_bytes_left(&ctx->gbc));
366  if (tex_size < (avctx->coded_width / TEXTURE_BLOCK_W)
367  *(avctx->coded_height / TEXTURE_BLOCK_H)
368  *tex_rat[t]) {
369  av_log(avctx, AV_LOG_ERROR, "Insufficient data\n");
370  return AVERROR_INVALIDDATA;
371  }
372  } else {
373  /* Perform the second-stage decompression */
374  ret = av_reallocp(&ctx->tex_buf, ctx->tex_size);
375  if (ret < 0)
376  return ret;
377  memset(ctx->tex_buf, 0, ctx->tex_size);
378 
379  avctx->execute2(avctx, decompress_chunks_thread, NULL,
380  ctx->chunk_results, ctx->chunk_count);
381 
382  for (i = 0; i < ctx->chunk_count; i++) {
383  if (ctx->chunk_results[i] < 0)
384  return ctx->chunk_results[i];
385  }
386 
387  ctx->tex_data = ctx->tex_buf;
388  }
389 
390  /* Use the decompress function on the texture, one block per thread */
391  if (t == 0){
392  avctx->execute2(avctx, decompress_texture_thread, tframe.f, NULL, ctx->slice_count);
393  } else{
394  tframe.f = data;
395  avctx->execute2(avctx, decompress_texture2_thread, tframe.f, NULL, ctx->slice_count);
396  }
397  }
398 
399  /* Frame is ready to be output */
400  tframe.f->pict_type = AV_PICTURE_TYPE_I;
401  tframe.f->key_frame = 1;
402  *got_frame = 1;
403 
404  return avpkt->size;
405 }
406 
407 static av_cold int hap_init(AVCodecContext *avctx)
408 {
409  HapContext *ctx = avctx->priv_data;
410  const char *texture_name;
411  int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
412 
413  if (ret < 0) {
414  av_log(avctx, AV_LOG_ERROR, "Invalid video size %dx%d.\n",
415  avctx->width, avctx->height);
416  return ret;
417  }
418 
419  /* Since codec is based on 4x4 blocks, size is aligned to 4 */
420  avctx->coded_width = FFALIGN(avctx->width, TEXTURE_BLOCK_W);
421  avctx->coded_height = FFALIGN(avctx->height, TEXTURE_BLOCK_H);
422 
423  ff_texturedsp_init(&ctx->dxtc);
424 
425  ctx->texture_count = 1;
426  ctx->uncompress_pix_size = 4;
427 
428  switch (avctx->codec_tag) {
429  case MKTAG('H','a','p','1'):
430  texture_name = "DXT1";
431  ctx->tex_rat = 8;
432  ctx->tex_fun = ctx->dxtc.dxt1_block;
433  avctx->pix_fmt = AV_PIX_FMT_RGB0;
434  break;
435  case MKTAG('H','a','p','5'):
436  texture_name = "DXT5";
437  ctx->tex_rat = 16;
438  ctx->tex_fun = ctx->dxtc.dxt5_block;
439  avctx->pix_fmt = AV_PIX_FMT_RGBA;
440  break;
441  case MKTAG('H','a','p','Y'):
442  texture_name = "DXT5-YCoCg-scaled";
443  ctx->tex_rat = 16;
444  ctx->tex_fun = ctx->dxtc.dxt5ys_block;
445  avctx->pix_fmt = AV_PIX_FMT_RGB0;
446  break;
447  case MKTAG('H','a','p','A'):
448  texture_name = "RGTC1";
449  ctx->tex_rat = 8;
450  ctx->tex_fun = ctx->dxtc.rgtc1u_gray_block;
451  avctx->pix_fmt = AV_PIX_FMT_GRAY8;
452  ctx->uncompress_pix_size = 1;
453  break;
454  case MKTAG('H','a','p','M'):
455  texture_name = "DXT5-YCoCg-scaled / RGTC1";
456  ctx->tex_rat = 16;
457  ctx->tex_rat2 = 8;
458  ctx->tex_fun = ctx->dxtc.dxt5ys_block;
459  ctx->tex_fun2 = ctx->dxtc.rgtc1u_alpha_block;
460  avctx->pix_fmt = AV_PIX_FMT_RGBA;
461  ctx->texture_count = 2;
462  break;
463  default:
465  }
466 
467  av_log(avctx, AV_LOG_DEBUG, "%s texture\n", texture_name);
468 
469  ctx->slice_count = av_clip(avctx->thread_count, 1,
470  avctx->coded_height / TEXTURE_BLOCK_H);
471 
472  return 0;
473 }
474 
475 static av_cold int hap_close(AVCodecContext *avctx)
476 {
477  HapContext *ctx = avctx->priv_data;
478 
480 
481  return 0;
482 }
483 
485  .name = "hap",
486  .long_name = NULL_IF_CONFIG_SMALL("Vidvox Hap"),
487  .type = AVMEDIA_TYPE_VIDEO,
488  .id = AV_CODEC_ID_HAP,
489  .init = hap_init,
490  .decode = hap_decode,
491  .close = hap_close,
492  .priv_data_size = sizeof(HapContext),
495  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
497  .codec_tags = (const uint32_t []){
498  MKTAG('H','a','p','1'),
499  MKTAG('H','a','p','5'),
500  MKTAG('H','a','p','Y'),
501  MKTAG('H','a','p','A'),
502  MKTAG('H','a','p','M'),
504  },
505 };
#define av_cold
Definition: attributes.h:88
uint8_t
Libavcodec external API header.
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
Definition: bytestream.h:267
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
Definition: bytestream.h:158
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:137
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
Definition: bytestream.h:212
#define FFMIN(a, b)
Definition: common.h:105
#define MKTAG(a, b, c, d)
Definition: common.h:478
#define av_clip
Definition: common.h:122
#define NULL
Definition: coverity.c:32
long long int64_t
Definition: coverity.c:34
static AVFrame * frame
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:112
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:108
@ AV_CODEC_ID_HAP
Definition: codec_id.h:238
#define AVERROR_DECODER_NOT_FOUND
Decoder not found.
Definition: error.h:52
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:215
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
Definition: mem.c:161
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
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:320
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
av_cold void ff_hap_free_context(HapContext *ctx)
Definition: hap.c:50
int ff_hap_set_chunk_count(HapContext *ctx, int count, int first_in_frame)
Definition: hap.c:28
int ff_hap_parse_section_header(GetByteContext *gbc, int *section_size, enum HapSectionType *section_type)
Definition: hap.c:57
@ HAP_FMT_RGBDXT1
Definition: hap.h:34
@ HAP_FMT_YCOCGDXT5
Definition: hap.h:36
@ HAP_FMT_RGBADXT5
Definition: hap.h:35
@ HAP_FMT_RGTC1
Definition: hap.h:37
@ HAP_COMP_NONE
Definition: hap.h:41
@ HAP_COMP_SNAPPY
Definition: hap.h:42
@ HAP_COMP_COMPLEX
Definition: hap.h:43
HapSectionType
Definition: hap.h:46
@ HAP_ST_SIZE_TABLE
Definition: hap.h:49
@ HAP_ST_DECODE_INSTRUCTIONS
Definition: hap.h:47
@ HAP_ST_COMPRESSOR_TABLE
Definition: hap.h:48
@ HAP_ST_OFFSET_TABLE
Definition: hap.h:50
static int decompress_texture_thread_internal(AVCodecContext *avctx, void *arg, int slice, int thread_nb, int texture_num)
Definition: hapdec.c:252
static int decompress_texture2_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb)
Definition: hapdec.c:300
AVCodec ff_hap_decoder
Definition: hapdec.c:484
static av_cold int hap_init(AVCodecContext *avctx)
Definition: hapdec.c:407
static int hap_parse_frame_header(AVCodecContext *avctx)
Definition: hapdec.c:130
static av_cold int hap_close(AVCodecContext *avctx)
Definition: hapdec.c:475
static int decompress_texture_thread(AVCodecContext *avctx, void *arg, int slice, int thread_nb)
Definition: hapdec.c:294
static int hap_parse_decode_instructions(HapContext *ctx, int size)
Definition: hapdec.c:46
static int decompress_chunks_thread(AVCodecContext *avctx, void *arg, int chunk_nb, int thread_nb)
Definition: hapdec.c:224
static int hap_can_use_tex_in_place(HapContext *ctx)
Definition: hapdec.c:117
static int hap_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: hapdec.c:306
misc image utilities
int i
Definition: input.c:407
#define FF_CODEC_TAGS_END
AVCodec.codec_tags termination value.
Definition: internal.h:90
#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:41
#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:49
const char * arg
Definition: jacosubdec.c:67
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
#define FFALIGN(x, a)
Definition: macros.h:48
const char data[16]
Definition: mxf.c:142
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:238
FF_ENABLE_DEPRECATION_WARNINGS int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
int64_t ff_snappy_peek_uncompressed_length(GetByteContext *gb)
Get the uncompressed length of an input buffer compressed using the Snappy algorithm.
Definition: snappy.c:133
int ff_snappy_uncompress(GetByteContext *gb, uint8_t *buf, int64_t *size)
Decompress an input buffer using Snappy algorithm.
Definition: snappy.c:143
Snappy decompression.
main external API structure.
Definition: avcodec.h:536
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:746
int width
picture width / height.
Definition: avcodec.h:709
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:561
const struct AVCodec * codec
Definition: avcodec.h:545
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
Definition: avcodec.h:1777
int coded_height
Definition: avcodec.h:724
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
Definition: avcodec.h:1848
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:724
void * priv_data
Definition: avcodec.h:563
AVCodec.
Definition: codec.h:197
int(* update_thread_context)(struct AVCodecContext *dst, const struct AVCodecContext *src)
Copy necessary context variables from a previous thread context to the current one.
Definition: codec.h:260
const char * name
Name of the codec implementation.
Definition: codec.h:204
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:332
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:396
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:349
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:401
This structure stores compressed data.
Definition: packet.h:346
int size
Definition: packet.h:370
uint8_t * data
Definition: packet.h:369
const uint8_t * buffer
Definition: bytestream.h:34
Definition: hap.h:53
size_t compressed_size
Definition: hap.h:56
uint32_t compressed_offset
Definition: hap.h:55
int uncompressed_offset
Definition: hap.h:57
size_t uncompressed_size
Definition: hap.h:58
enum HapCompressor compressor
Definition: hap.h:54
Definition: hap.h:61
AVFrame * f
Definition: thread.h:35
#define av_log(a,...)
AVFormatContext * ctx
Definition: movenc.c:48
av_cold void ff_texturedsp_init(TextureDSPContext *c)
Definition: texturedsp.c:640
Texture block (4x4) module.
#define TEXTURE_BLOCK_W
Definition: texturedsp.h:42
#define TEXTURE_BLOCK_H
Definition: texturedsp.h:43
int size