FFmpeg
dxvenc.c
Go to the documentation of this file.
1 /*
2  * Resolume DXV encoder
3  * Copyright (C) 2024 Connor Worley <connorbworley@gmail.com>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include <stdint.h>
23 
24 #include "libavutil/crc.h"
25 #include "libavutil/imgutils.h"
26 #include "libavutil/opt.h"
27 
28 #include "bytestream.h"
29 #include "codec_internal.h"
30 #include "dxv.h"
31 #include "encode.h"
32 #include "texturedsp.h"
33 
34 #define DXV_HEADER_LENGTH 12
35 
36 /*
37  * DXV uses LZ-like back-references to avoid copying words that have already
38  * appeared in the decompressed stream. Using a simple hash table (HT)
39  * significantly speeds up the lookback process while encoding.
40  */
41 #define LOOKBACK_HT_ELEMS 0x40000
42 #define LOOKBACK_WORDS 0x20202
43 
44 typedef struct HTEntry {
45  uint32_t key;
46  uint32_t pos;
47 } HTEntry;
48 
49 static void ht_init(HTEntry *ht)
50 {
51  for (size_t i = 0; i < LOOKBACK_HT_ELEMS; i++) {
52  ht[i].pos = -1;
53  }
54 }
55 
56 static uint32_t ht_lookup_and_upsert(HTEntry *ht, const AVCRC *hash_ctx,
57  uint32_t key, uint32_t pos)
58 {
59  uint32_t ret = -1;
60  size_t hash = av_crc(hash_ctx, 0, (uint8_t*)&key, 4) % LOOKBACK_HT_ELEMS;
61  for (size_t i = hash; i < hash + LOOKBACK_HT_ELEMS; i++) {
62  size_t wrapped_index = i % LOOKBACK_HT_ELEMS;
63  HTEntry *entry = &ht[wrapped_index];
64  if (entry->key == key || entry->pos == -1) {
65  ret = entry->pos;
66  entry->key = key;
67  entry->pos = pos;
68  break;
69  }
70  }
71  return ret;
72 }
73 
74 static void ht_delete(HTEntry *ht, const AVCRC *hash_ctx,
75  uint32_t key, uint32_t pos)
76 {
77  HTEntry *removed_entry = NULL;
78  size_t removed_hash;
79  size_t hash = av_crc(hash_ctx, 0, (uint8_t*)&key, 4) % LOOKBACK_HT_ELEMS;
80 
81  for (size_t i = hash; i < hash + LOOKBACK_HT_ELEMS; i++) {
82  size_t wrapped_index = i % LOOKBACK_HT_ELEMS;
83  HTEntry *entry = &ht[wrapped_index];
84  if (entry->pos == -1)
85  return;
86  if (removed_entry) {
87  size_t candidate_hash = av_crc(hash_ctx, 0, (uint8_t*)&entry->key, 4) % LOOKBACK_HT_ELEMS;
88  if ((wrapped_index > removed_hash && (candidate_hash <= removed_hash || candidate_hash > wrapped_index)) ||
89  (wrapped_index < removed_hash && (candidate_hash <= removed_hash && candidate_hash > wrapped_index))) {
90  *removed_entry = *entry;
91  entry->pos = -1;
92  removed_entry = entry;
93  removed_hash = wrapped_index;
94  }
95  } else if (entry->key == key) {
96  if (entry->pos <= pos) {
97  entry->pos = -1;
98  removed_entry = entry;
99  removed_hash = wrapped_index;
100  } else {
101  return;
102  }
103  }
104  }
105 }
106 
107 typedef struct DXVEncContext {
108  AVClass *class;
109 
111 
112  uint8_t *tex_data; // Compressed texture
113  int64_t tex_size; // Texture size
114 
115  /* Optimal number of slices for parallel decoding */
117 
119 
122 
123  const AVCRC *crc_ctx;
124 
127 } DXVEncContext;
128 
129 /* Converts an index offset value to a 2-bit opcode and pushes it to a stream.
130  * Inverse of CHECKPOINT in dxv.c. */
131 #define PUSH_OP(x) \
132  do { \
133  if (state == 16) { \
134  if (bytestream2_get_bytes_left_p(pbc) < 4) { \
135  return AVERROR_INVALIDDATA; \
136  } \
137  value = pbc->buffer; \
138  bytestream2_put_le32(pbc, 0); \
139  state = 0; \
140  } \
141  if (idx >= 0x102 * x) { \
142  op = 3; \
143  bytestream2_put_le16(pbc, (idx / x) - 0x102); \
144  } else if (idx >= 2 * x) { \
145  op = 2; \
146  bytestream2_put_byte(pbc, (idx / x) - 2); \
147  } else if (idx == x) { \
148  op = 1; \
149  } else { \
150  op = 0; \
151  } \
152  AV_WL32(value, AV_RL32(value) | (op << (state * 2))); \
153  state++; \
154  } while (0)
155 
157 {
158  DXVEncContext *ctx = avctx->priv_data;
159  PutByteContext *pbc = &ctx->pbc;
160  void *value;
161  uint32_t color, lut, idx, color_idx, lut_idx, prev_pos, state = 16, pos = 2, op = 0;
162 
163  ht_init(ctx->color_lookback_ht);
164  ht_init(ctx->lut_lookback_ht);
165 
166  bytestream2_put_le32(pbc, AV_RL32(ctx->tex_data));
167  bytestream2_put_le32(pbc, AV_RL32(ctx->tex_data + 4));
168 
169  ht_lookup_and_upsert(ctx->color_lookback_ht, ctx->crc_ctx, AV_RL32(ctx->tex_data), 0);
170  ht_lookup_and_upsert(ctx->lut_lookback_ht, ctx->crc_ctx, AV_RL32(ctx->tex_data + 4), 1);
171 
172  while (pos + 2 <= ctx->tex_size / 4) {
173  idx = 0;
174 
175  color = AV_RL32(ctx->tex_data + pos * 4);
176  prev_pos = ht_lookup_and_upsert(ctx->color_lookback_ht, ctx->crc_ctx, color, pos);
177  color_idx = prev_pos != -1 ? pos - prev_pos : 0;
178  if (pos >= LOOKBACK_WORDS) {
179  uint32_t old_pos = pos - LOOKBACK_WORDS;
180  uint32_t old_color = AV_RL32(ctx->tex_data + old_pos * 4);
181  ht_delete(ctx->color_lookback_ht, ctx->crc_ctx, old_color, old_pos);
182  }
183  pos++;
184 
185  lut = AV_RL32(ctx->tex_data + pos * 4);
186  if (color_idx && lut == AV_RL32(ctx->tex_data + (pos - color_idx) * 4)) {
187  idx = color_idx;
188  } else {
189  idx = 0;
190  prev_pos = ht_lookup_and_upsert(ctx->lut_lookback_ht, ctx->crc_ctx, lut, pos);
191  lut_idx = prev_pos != -1 ? pos - prev_pos : 0;
192  }
193  if (pos >= LOOKBACK_WORDS) {
194  uint32_t old_pos = pos - LOOKBACK_WORDS;
195  uint32_t old_lut = AV_RL32(ctx->tex_data + old_pos * 4);
196  ht_delete(ctx->lut_lookback_ht, ctx->crc_ctx, old_lut, old_pos);
197  }
198  pos++;
199 
200  PUSH_OP(2);
201 
202  if (!idx) {
203  idx = color_idx;
204  PUSH_OP(2);
205  if (!idx)
206  bytestream2_put_le32(pbc, color);
207 
208  idx = lut_idx;
209  PUSH_OP(2);
210  if (!idx)
211  bytestream2_put_le32(pbc, lut);
212  }
213  }
214 
215  return 0;
216 }
217 
218 static int dxv_encode(AVCodecContext *avctx, AVPacket *pkt,
219  const AVFrame *frame, int *got_packet)
220 {
221  DXVEncContext *ctx = avctx->priv_data;
222  PutByteContext *pbc = &ctx->pbc;
223  int ret;
224 
225  /* unimplemented: needs to depend on compression ratio of tex format */
226  /* under DXT1, we need 3 words to encode load ops for 32 words.
227  * the first 2 words of the texture do not need load ops. */
228  ret = ff_alloc_packet(avctx, pkt, DXV_HEADER_LENGTH + ctx->tex_size + AV_CEIL_RSHIFT(ctx->tex_size - 8, 7) * 12);
229  if (ret < 0)
230  return ret;
231 
232  if (ctx->enc.tex_funct) {
233  ctx->enc.tex_data.out = ctx->tex_data;
234  ctx->enc.frame_data.in = frame->data[0];
235  ctx->enc.stride = frame->linesize[0];
236  ctx->enc.width = avctx->width;
237  ctx->enc.height = avctx->height;
239  } else {
240  /* unimplemented: YCoCg formats */
241  return AVERROR_INVALIDDATA;
242  }
243 
245 
246  bytestream2_put_le32(pbc, ctx->tex_fmt);
247  bytestream2_put_byte(pbc, 4);
248  bytestream2_put_byte(pbc, 0);
249  bytestream2_put_byte(pbc, 0);
250  bytestream2_put_byte(pbc, 0);
251  /* Fill in compressed size later */
252  bytestream2_skip_p(pbc, 4);
253 
254  ret = ctx->compress_tex(avctx);
255  if (ret < 0)
256  return ret;
257 
260 
261  *got_packet = 1;
262  return 0;
263 }
264 
265 static av_cold int dxv_init(AVCodecContext *avctx)
266 {
267  DXVEncContext *ctx = avctx->priv_data;
268  TextureDSPEncContext texdsp;
269  int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
270 
271  if (ret < 0) {
272  av_log(avctx, AV_LOG_ERROR, "Invalid image size %dx%d.\n",
273  avctx->width, avctx->height);
274  return ret;
275  }
276 
277  if (avctx->width % TEXTURE_BLOCK_W || avctx->height % TEXTURE_BLOCK_H) {
278  av_log(avctx,
279  AV_LOG_ERROR,
280  "Video size %dx%d is not multiple of "AV_STRINGIFY(TEXTURE_BLOCK_W)"x"AV_STRINGIFY(TEXTURE_BLOCK_H)".\n",
281  avctx->width, avctx->height);
282  return AVERROR_INVALIDDATA;
283  }
284 
285  ff_texturedspenc_init(&texdsp);
286 
287  switch (ctx->tex_fmt) {
288  case DXV_FMT_DXT1:
289  ctx->compress_tex = dxv_compress_dxt1;
290  ctx->enc.tex_funct = texdsp.dxt1_block;
291  ctx->enc.tex_ratio = 8;
292  break;
293  default:
294  av_log(avctx, AV_LOG_ERROR, "Invalid format %08X\n", ctx->tex_fmt);
295  return AVERROR_INVALIDDATA;
296  }
297  ctx->enc.raw_ratio = 16;
298  ctx->tex_size = avctx->width / TEXTURE_BLOCK_W *
299  avctx->height / TEXTURE_BLOCK_H *
300  ctx->enc.tex_ratio;
301  ctx->enc.slice_count = av_clip(avctx->thread_count, 1, avctx->height / TEXTURE_BLOCK_H);
302 
303  ctx->tex_data = av_malloc(ctx->tex_size);
304  if (!ctx->tex_data) {
305  return AVERROR(ENOMEM);
306  }
307 
308  ctx->crc_ctx = av_crc_get_table(AV_CRC_32_IEEE);
309  if (!ctx->crc_ctx) {
310  av_log(avctx, AV_LOG_ERROR, "Could not initialize CRC table.\n");
311  return AVERROR_BUG;
312  }
313 
314  return 0;
315 }
316 
317 static av_cold int dxv_close(AVCodecContext *avctx)
318 {
319  DXVEncContext *ctx = avctx->priv_data;
320 
321  av_freep(&ctx->tex_data);
322 
323  return 0;
324 }
325 
326 #define OFFSET(x) offsetof(DXVEncContext, x)
327 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
328 static const AVOption options[] = {
329  { "format", NULL, OFFSET(tex_fmt), AV_OPT_TYPE_INT, { .i64 = DXV_FMT_DXT1 }, DXV_FMT_DXT1, DXV_FMT_DXT1, FLAGS, .unit = "format" },
330  { "dxt1", "DXT1 (Normal Quality, No Alpha)", 0, AV_OPT_TYPE_CONST, { .i64 = DXV_FMT_DXT1 }, 0, 0, FLAGS, .unit = "format" },
331  { NULL },
332 };
333 
334 static const AVClass dxvenc_class = {
335  .class_name = "DXV encoder",
336  .option = options,
337  .version = LIBAVUTIL_VERSION_INT,
338 };
339 
341  .p.name = "dxv",
342  CODEC_LONG_NAME("Resolume DXV"),
343  .p.type = AVMEDIA_TYPE_VIDEO,
344  .p.id = AV_CODEC_ID_DXV,
345  .init = dxv_init,
347  .close = dxv_close,
348  .priv_data_size = sizeof(DXVEncContext),
349  .p.capabilities = AV_CODEC_CAP_DR1 |
352  .p.priv_class = &dxvenc_class,
353  .p.pix_fmts = (const enum AVPixelFormat[]) {
355  },
356  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
357 };
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
DXV_FMT_DXT1
@ DXV_FMT_DXT1
Definition: dxv.h:28
entry
#define entry
Definition: aom_film_grain_template.c:66
av_clip
#define av_clip
Definition: common.h:98
DXVEncContext
Definition: dxvenc.c:107
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: codec_internal.h:42
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
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:424
TEXTURE_BLOCK_H
#define TEXTURE_BLOCK_H
Definition: texturedsp.h:43
color
Definition: vf_paletteuse.c:511
AVCRC
uint32_t AVCRC
Definition: crc.h:46
dxvenc_class
static const AVClass dxvenc_class
Definition: dxvenc.c:334
int64_t
long long int64_t
Definition: coverity.c:34
ff_dxv_encoder
const FFCodec ff_dxv_encoder
Definition: dxvenc.c:340
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
HTEntry::pos
uint32_t pos
Definition: dxvenc.c:46
HTEntry
Definition: dxvenc.c:44
AVPacket::data
uint8_t * data
Definition: packet.h:522
TextureDSPEncContext
Definition: texturedsp.h:63
AVOption
AVOption.
Definition: opt.h:346
encode.h
bytestream2_tell_p
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
Definition: bytestream.h:197
OFFSET
#define OFFSET(x)
Definition: dxvenc.c:326
FFCodec
Definition: codec_internal.h:127
HTEntry::key
uint32_t key
Definition: dxvenc.c:45
hash
uint8_t hash[HASH_SIZE]
Definition: movenc.c:57
LOOKBACK_WORDS
#define LOOKBACK_WORDS
Definition: dxvenc.c:42
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:365
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
crc.h
DXVEncContext::lut_lookback_ht
HTEntry lut_lookback_ht[LOOKBACK_HT_ELEMS]
Definition: dxvenc.c:126
texturedsp.h
ff_texturedspenc_init
void ff_texturedspenc_init(TextureDSPEncContext *c)
Definition: texturedspenc.c:650
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AVCodecContext::thread_count
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
Definition: avcodec.h:1582
av_shrink_packet
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:113
DXVEncContext::enc
TextureDSPThreadContext enc
Definition: dxvenc.c:118
DXV_HEADER_LENGTH
#define DXV_HEADER_LENGTH
Definition: dxvenc.c:34
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:296
dxv_encode
static int dxv_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: dxvenc.c:218
TextureDSPThreadContext
Definition: texturedsp.h:69
LOOKBACK_HT_ELEMS
#define LOOKBACK_HT_ELEMS
Definition: dxvenc.c:41
options
static const AVOption options[]
Definition: dxvenc.c:328
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
DXVEncContext::tex_data
uint8_t * tex_data
Definition: dxvenc.c:112
bytestream2_init_writer
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
Definition: bytestream.h:147
DXVEncContext::color_lookback_ht
HTEntry color_lookback_ht[LOOKBACK_HT_ELEMS]
Definition: dxvenc.c:125
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
op
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
Definition: anm.c:76
dxv_compress_dxt1
static int dxv_compress_dxt1(AVCodecContext *avctx)
Definition: dxvenc.c:156
DXVEncContext::crc_ctx
const AVCRC * crc_ctx
Definition: dxvenc.c:123
ctx
AVFormatContext * ctx
Definition: movenc.c:48
key
const char * key
Definition: hwcontext_opencl.c:189
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
frame
static AVFrame * frame
Definition: demux_decode.c:54
DXVTextureFormat
DXVTextureFormat
Definition: dxv.h:27
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
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
DXVEncContext::slice_count
int slice_count
Definition: dxvenc.c:116
state
static struct @385 state
ht_lookup_and_upsert
static uint32_t ht_lookup_and_upsert(HTEntry *ht, const AVCRC *hash_ctx, uint32_t key, uint32_t pos)
Definition: dxvenc.c:56
dxv_close
static av_cold int dxv_close(AVCodecContext *avctx)
Definition: dxvenc.c:317
PutByteContext
Definition: bytestream.h:37
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AVPacket::size
int size
Definition: packet.h:523
codec_internal.h
dxv_init
static av_cold int dxv_init(AVCodecContext *avctx)
Definition: dxvenc.c:265
AV_CODEC_ID_DXV
@ AV_CODEC_ID_DXV
Definition: codec_id.h:243
color
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
Definition: log.c:94
ff_texturedsp_exec_compress_threads
int ff_texturedsp_exec_compress_threads(struct AVCodecContext *avctx, TextureDSPThreadContext *ctx)
DXVEncContext::tex_size
int64_t tex_size
Definition: dxvenc.c:113
DXVEncContext::pbc
PutByteContext pbc
Definition: dxvenc.c:110
av_crc_get_table
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
Definition: crc.c:374
AV_CODEC_CAP_SLICE_THREADS
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:114
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
bytestream2_skip_p
static av_always_inline void bytestream2_skip_p(PutByteContext *p, unsigned int size)
Definition: bytestream.h:180
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
AV_STRINGIFY
#define AV_STRINGIFY(s)
Definition: macros.h:66
TEXTURE_BLOCK_W
#define TEXTURE_BLOCK_W
Definition: texturedsp.h:42
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
ht_init
static void ht_init(HTEntry *ht)
Definition: dxvenc.c:49
AV_CRC_32_IEEE
@ AV_CRC_32_IEEE
Definition: crc.h:52
AVCodecContext::height
int height
Definition: avcodec.h:618
FLAGS
#define FLAGS
Definition: dxvenc.c:327
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
DXVEncContext::tex_fmt
DXVTextureFormat tex_fmt
Definition: dxvenc.c:120
pos
unsigned int pos
Definition: spdifenc.c:413
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
ht_delete
static void ht_delete(HTEntry *ht, const AVCRC *hash_ctx, uint32_t key, uint32_t pos)
Definition: dxvenc.c:74
AVCodecContext
main external API structure.
Definition: avcodec.h:445
TextureDSPEncContext::dxt1_block
int(* dxt1_block)(uint8_t *dst, ptrdiff_t stride, const uint8_t *block)
Definition: texturedsp.h:64
av_crc
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
Definition: crc.c:392
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
PUSH_OP
#define PUSH_OP(x)
Definition: dxvenc.c:131
DXVEncContext::compress_tex
int(* compress_tex)(AVCodecContext *avctx)
Definition: dxvenc.c:121
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
dxv.h
AVPacket
This structure stores compressed data.
Definition: packet.h:499
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:472
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:618
bytestream.h
imgutils.h
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:389
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
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
int
int
Definition: ffmpeg_filter.c:409
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
ff_alloc_packet
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
Definition: encode.c:61