FFmpeg
kmvc.c
Go to the documentation of this file.
1 /*
2  * KMVC decoder
3  * Copyright (c) 2006 Konstantin Shishkov
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 /**
23  * @file
24  * Karl Morton's Video Codec decoder
25  */
26 
27 #include <stdio.h>
28 #include <stdlib.h>
29 
30 #include "avcodec.h"
31 #include "bytestream.h"
32 #include "internal.h"
33 #include "libavutil/common.h"
34 
35 #define KMVC_KEYFRAME 0x80
36 #define KMVC_PALETTE 0x40
37 #define KMVC_METHOD 0x0F
38 #define MAX_PALSIZE 256
39 
40 /*
41  * Decoder context
42  */
43 typedef struct KmvcContext {
45 
46  int setpal;
47  int palsize;
48  uint32_t pal[MAX_PALSIZE];
50  uint8_t frm0[320 * 200], frm1[320 * 200];
52 } KmvcContext;
53 
54 typedef struct BitBuf {
55  int bits;
56  int bitbuf;
57 } BitBuf;
58 
59 #define BLK(data, x, y) data[av_clip((x) + (y) * 320, 0, 320 * 200 -1)]
60 
61 #define kmvc_init_getbits(bb, g) bb.bits = 7; bb.bitbuf = bytestream2_get_byte(g);
62 
63 #define kmvc_getbit(bb, g, res) {\
64  res = 0; \
65  if (bb.bitbuf & (1 << bb.bits)) res = 1; \
66  bb.bits--; \
67  if(bb.bits == -1) { \
68  bb.bitbuf = bytestream2_get_byte(g); \
69  bb.bits = 7; \
70  } \
71 }
72 
73 static int kmvc_decode_intra_8x8(KmvcContext * ctx, int w, int h)
74 {
75  BitBuf bb;
76  int res, val;
77  int i, j;
78  int bx, by;
79  int l0x, l1x, l0y, l1y;
80  int mx, my;
81 
82  kmvc_init_getbits(bb, &ctx->g);
83 
84  for (by = 0; by < h; by += 8)
85  for (bx = 0; bx < w; bx += 8) {
86  if (!bytestream2_get_bytes_left(&ctx->g)) {
87  av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
88  return AVERROR_INVALIDDATA;
89  }
90  kmvc_getbit(bb, &ctx->g, res);
91  if (!res) { // fill whole 8x8 block
92  val = bytestream2_get_byte(&ctx->g);
93  for (i = 0; i < 64; i++)
94  BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) = val;
95  } else { // handle four 4x4 subblocks
96  for (i = 0; i < 4; i++) {
97  l0x = bx + (i & 1) * 4;
98  l0y = by + (i & 2) * 2;
99  kmvc_getbit(bb, &ctx->g, res);
100  if (!res) {
101  kmvc_getbit(bb, &ctx->g, res);
102  if (!res) { // fill whole 4x4 block
103  val = bytestream2_get_byte(&ctx->g);
104  for (j = 0; j < 16; j++)
105  BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val;
106  } else { // copy block from already decoded place
107  val = bytestream2_get_byte(&ctx->g);
108  mx = val & 0xF;
109  my = val >> 4;
110  if ((l0x-mx) + 320*(l0y-my) < 0 || (l0x-mx) + 320*(l0y-my) > 320*197 - 4) {
111  av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
112  return AVERROR_INVALIDDATA;
113  }
114  for (j = 0; j < 16; j++)
115  BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) =
116  BLK(ctx->cur, l0x + (j & 3) - mx, l0y + (j >> 2) - my);
117  }
118  } else { // descend to 2x2 sub-sub-blocks
119  for (j = 0; j < 4; j++) {
120  l1x = l0x + (j & 1) * 2;
121  l1y = l0y + (j & 2);
122  kmvc_getbit(bb, &ctx->g, res);
123  if (!res) {
124  kmvc_getbit(bb, &ctx->g, res);
125  if (!res) { // fill whole 2x2 block
126  val = bytestream2_get_byte(&ctx->g);
127  BLK(ctx->cur, l1x, l1y) = val;
128  BLK(ctx->cur, l1x + 1, l1y) = val;
129  BLK(ctx->cur, l1x, l1y + 1) = val;
130  BLK(ctx->cur, l1x + 1, l1y + 1) = val;
131  } else { // copy block from already decoded place
132  val = bytestream2_get_byte(&ctx->g);
133  mx = val & 0xF;
134  my = val >> 4;
135  if ((l1x-mx) + 320*(l1y-my) < 0 || (l1x-mx) + 320*(l1y-my) > 320*199 - 2) {
136  av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
137  return AVERROR_INVALIDDATA;
138  }
139  BLK(ctx->cur, l1x, l1y) = BLK(ctx->cur, l1x - mx, l1y - my);
140  BLK(ctx->cur, l1x + 1, l1y) =
141  BLK(ctx->cur, l1x + 1 - mx, l1y - my);
142  BLK(ctx->cur, l1x, l1y + 1) =
143  BLK(ctx->cur, l1x - mx, l1y + 1 - my);
144  BLK(ctx->cur, l1x + 1, l1y + 1) =
145  BLK(ctx->cur, l1x + 1 - mx, l1y + 1 - my);
146  }
147  } else { // read values for block
148  BLK(ctx->cur, l1x, l1y) = bytestream2_get_byte(&ctx->g);
149  BLK(ctx->cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->g);
150  BLK(ctx->cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->g);
151  BLK(ctx->cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->g);
152  }
153  }
154  }
155  }
156  }
157  }
158 
159  return 0;
160 }
161 
162 static int kmvc_decode_inter_8x8(KmvcContext * ctx, int w, int h)
163 {
164  BitBuf bb;
165  int res, val;
166  int i, j;
167  int bx, by;
168  int l0x, l1x, l0y, l1y;
169  int mx, my;
170 
171  kmvc_init_getbits(bb, &ctx->g);
172 
173  for (by = 0; by < h; by += 8)
174  for (bx = 0; bx < w; bx += 8) {
175  kmvc_getbit(bb, &ctx->g, res);
176  if (!res) {
177  kmvc_getbit(bb, &ctx->g, res);
178  if (!res) { // fill whole 8x8 block
179  if (!bytestream2_get_bytes_left(&ctx->g)) {
180  av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
181  return AVERROR_INVALIDDATA;
182  }
183  val = bytestream2_get_byte(&ctx->g);
184  for (i = 0; i < 64; i++)
185  BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) = val;
186  } else { // copy block from previous frame
187  for (i = 0; i < 64; i++)
188  BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) =
189  BLK(ctx->prev, bx + (i & 0x7), by + (i >> 3));
190  }
191  } else { // handle four 4x4 subblocks
192  if (!bytestream2_get_bytes_left(&ctx->g)) {
193  av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
194  return AVERROR_INVALIDDATA;
195  }
196  for (i = 0; i < 4; i++) {
197  l0x = bx + (i & 1) * 4;
198  l0y = by + (i & 2) * 2;
199  kmvc_getbit(bb, &ctx->g, res);
200  if (!res) {
201  kmvc_getbit(bb, &ctx->g, res);
202  if (!res) { // fill whole 4x4 block
203  val = bytestream2_get_byte(&ctx->g);
204  for (j = 0; j < 16; j++)
205  BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val;
206  } else { // copy block
207  val = bytestream2_get_byte(&ctx->g);
208  mx = (val & 0xF) - 8;
209  my = (val >> 4) - 8;
210  if ((l0x+mx) + 320*(l0y+my) < 0 || (l0x+mx) + 320*(l0y+my) > 320*197 - 4) {
211  av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
212  return AVERROR_INVALIDDATA;
213  }
214  for (j = 0; j < 16; j++)
215  BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) =
216  BLK(ctx->prev, l0x + (j & 3) + mx, l0y + (j >> 2) + my);
217  }
218  } else { // descend to 2x2 sub-sub-blocks
219  for (j = 0; j < 4; j++) {
220  l1x = l0x + (j & 1) * 2;
221  l1y = l0y + (j & 2);
222  kmvc_getbit(bb, &ctx->g, res);
223  if (!res) {
224  kmvc_getbit(bb, &ctx->g, res);
225  if (!res) { // fill whole 2x2 block
226  val = bytestream2_get_byte(&ctx->g);
227  BLK(ctx->cur, l1x, l1y) = val;
228  BLK(ctx->cur, l1x + 1, l1y) = val;
229  BLK(ctx->cur, l1x, l1y + 1) = val;
230  BLK(ctx->cur, l1x + 1, l1y + 1) = val;
231  } else { // copy block
232  val = bytestream2_get_byte(&ctx->g);
233  mx = (val & 0xF) - 8;
234  my = (val >> 4) - 8;
235  if ((l1x+mx) + 320*(l1y+my) < 0 || (l1x+mx) + 320*(l1y+my) > 320*199 - 2) {
236  av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
237  return AVERROR_INVALIDDATA;
238  }
239  BLK(ctx->cur, l1x, l1y) = BLK(ctx->prev, l1x + mx, l1y + my);
240  BLK(ctx->cur, l1x + 1, l1y) =
241  BLK(ctx->prev, l1x + 1 + mx, l1y + my);
242  BLK(ctx->cur, l1x, l1y + 1) =
243  BLK(ctx->prev, l1x + mx, l1y + 1 + my);
244  BLK(ctx->cur, l1x + 1, l1y + 1) =
245  BLK(ctx->prev, l1x + 1 + mx, l1y + 1 + my);
246  }
247  } else { // read values for block
248  BLK(ctx->cur, l1x, l1y) = bytestream2_get_byte(&ctx->g);
249  BLK(ctx->cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->g);
250  BLK(ctx->cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->g);
251  BLK(ctx->cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->g);
252  }
253  }
254  }
255  }
256  }
257  }
258 
259  return 0;
260 }
261 
262 static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame,
263  AVPacket *avpkt)
264 {
265  KmvcContext *const ctx = avctx->priv_data;
266  AVFrame *frame = data;
267  uint8_t *out, *src;
268  int i, ret;
269  int header;
270  int blocksize;
271  int pal_size;
272  const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
273 
274  bytestream2_init(&ctx->g, avpkt->data, avpkt->size);
275 
276  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
277  return ret;
278 
279  header = bytestream2_get_byte(&ctx->g);
280 
281  /* blocksize 127 is really palette change event */
282  if (bytestream2_peek_byte(&ctx->g) == 127) {
283  bytestream2_skip(&ctx->g, 3);
284  for (i = 0; i < 127; i++) {
285  ctx->pal[i + (header & 0x81)] = 0xFFU << 24 | bytestream2_get_be24(&ctx->g);
286  bytestream2_skip(&ctx->g, 1);
287  }
288  bytestream2_seek(&ctx->g, -127 * 4 - 3, SEEK_CUR);
289  }
290 
291  if (header & KMVC_KEYFRAME) {
292  frame->key_frame = 1;
293  frame->pict_type = AV_PICTURE_TYPE_I;
294  } else {
295  frame->key_frame = 0;
296  frame->pict_type = AV_PICTURE_TYPE_P;
297  }
298 
299  if (header & KMVC_PALETTE) {
300  frame->palette_has_changed = 1;
301  // palette starts from index 1 and has 127 entries
302  for (i = 1; i <= ctx->palsize; i++) {
303  ctx->pal[i] = 0xFFU << 24 | bytestream2_get_be24(&ctx->g);
304  }
305  }
306 
307  if (pal && pal_size == AVPALETTE_SIZE) {
308  frame->palette_has_changed = 1;
309  memcpy(ctx->pal, pal, AVPALETTE_SIZE);
310  } else if (pal) {
311  av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size);
312  }
313 
314  if (ctx->setpal) {
315  ctx->setpal = 0;
316  frame->palette_has_changed = 1;
317  }
318 
319  /* make the palette available on the way out */
320  memcpy(frame->data[1], ctx->pal, 1024);
321 
322  blocksize = bytestream2_get_byte(&ctx->g);
323 
324  if (blocksize != 8 && blocksize != 127) {
325  av_log(avctx, AV_LOG_ERROR, "Block size = %i\n", blocksize);
326  return AVERROR_INVALIDDATA;
327  }
328  memset(ctx->cur, 0, 320 * 200);
329  switch (header & KMVC_METHOD) {
330  case 0:
331  case 1: // used in palette changed event
332  memcpy(ctx->cur, ctx->prev, 320 * 200);
333  break;
334  case 3:
335  kmvc_decode_intra_8x8(ctx, avctx->width, avctx->height);
336  break;
337  case 4:
338  kmvc_decode_inter_8x8(ctx, avctx->width, avctx->height);
339  break;
340  default:
341  av_log(avctx, AV_LOG_ERROR, "Unknown compression method %i\n", header & KMVC_METHOD);
342  return AVERROR_INVALIDDATA;
343  }
344 
345  out = frame->data[0];
346  src = ctx->cur;
347  for (i = 0; i < avctx->height; i++) {
348  memcpy(out, src, avctx->width);
349  src += 320;
350  out += frame->linesize[0];
351  }
352 
353  /* flip buffers */
354  if (ctx->cur == ctx->frm0) {
355  ctx->cur = ctx->frm1;
356  ctx->prev = ctx->frm0;
357  } else {
358  ctx->cur = ctx->frm0;
359  ctx->prev = ctx->frm1;
360  }
361 
362  *got_frame = 1;
363 
364  /* always report that the buffer was completely consumed */
365  return avpkt->size;
366 }
367 
368 
369 
370 /*
371  * Init kmvc decoder
372  */
373 static av_cold int decode_init(AVCodecContext * avctx)
374 {
375  KmvcContext *const c = avctx->priv_data;
376  int i;
377 
378  c->avctx = avctx;
379 
380  if (avctx->width > 320 || avctx->height > 200) {
381  av_log(avctx, AV_LOG_ERROR, "KMVC supports frames <= 320x200\n");
382  return AVERROR(EINVAL);
383  }
384 
385  c->cur = c->frm0;
386  c->prev = c->frm1;
387 
388  for (i = 0; i < 256; i++) {
389  c->pal[i] = 0xFFU << 24 | i * 0x10101;
390  }
391 
392  if (avctx->extradata_size < 12) {
393  av_log(avctx, AV_LOG_WARNING,
394  "Extradata missing, decoding may not work properly...\n");
395  c->palsize = 127;
396  } else {
397  c->palsize = AV_RL16(avctx->extradata + 10);
398  if (c->palsize >= (unsigned)MAX_PALSIZE) {
399  c->palsize = 127;
400  av_log(avctx, AV_LOG_ERROR, "KMVC palette too large\n");
401  return AVERROR_INVALIDDATA;
402  }
403  }
404 
405  if (avctx->extradata_size == 1036) { // palette in extradata
406  uint8_t *src = avctx->extradata + 12;
407  for (i = 0; i < 256; i++) {
408  c->pal[i] = AV_RL32(src);
409  src += 4;
410  }
411  c->setpal = 1;
412  }
413 
414  avctx->pix_fmt = AV_PIX_FMT_PAL8;
415 
416  return 0;
417 }
418 
420  .name = "kmvc",
421  .long_name = NULL_IF_CONFIG_SMALL("Karl Morton's video codec"),
422  .type = AVMEDIA_TYPE_VIDEO,
423  .id = AV_CODEC_ID_KMVC,
424  .priv_data_size = sizeof(KmvcContext),
425  .init = decode_init,
426  .decode = decode_frame,
427  .capabilities = AV_CODEC_CAP_DR1,
428 };
AVCodec
AVCodec.
Definition: avcodec.h:3481
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
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
out
FILE * out
Definition: movenc.c:54
GetByteContext
Definition: bytestream.h:33
KmvcContext
Definition: kmvc.c:43
KmvcContext::prev
uint8_t * prev
Definition: kmvc.c:49
bytestream2_seek
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
Definition: bytestream.h:208
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
w
uint8_t w
Definition: llviddspenc.c:38
internal.h
AVPacket::data
uint8_t * data
Definition: avcodec.h:1477
kmvc_decode_intra_8x8
static int kmvc_decode_intra_8x8(KmvcContext *ctx, int w, int h)
Definition: kmvc.c:73
AV_PKT_DATA_PALETTE
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
Definition: avcodec.h:1190
data
const char data[16]
Definition: mxf.c:91
KmvcContext::palsize
int palsize
Definition: kmvc.c:47
KMVC_KEYFRAME
#define KMVC_KEYFRAME
Definition: kmvc.c:35
KmvcContext::frm0
uint8_t frm0[320 *200]
Definition: kmvc.c:50
bytestream2_get_bytes_left
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
Definition: bytestream.h:154
bytestream2_skip
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:164
U
#define U(x)
Definition: vp56_arith.h:37
src
#define src
Definition: vp8dsp.c:254
ff_kmvc_decoder
AVCodec ff_kmvc_decoder
Definition: kmvc.c:419
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
av_cold
#define av_cold
Definition: attributes.h:84
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:1667
AV_CODEC_ID_KMVC
@ AV_CODEC_ID_KMVC
Definition: avcodec.h:303
kmvc_getbit
#define kmvc_getbit(bb, g, res)
Definition: kmvc.c:63
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_RL16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
Definition: bytestream.h:90
KMVC_METHOD
#define KMVC_METHOD
Definition: kmvc.c:37
KmvcContext::cur
uint8_t * cur
Definition: kmvc.c:49
av_packet_get_side_data
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
Definition: avpacket.c:350
AVPALETTE_SIZE
#define AVPALETTE_SIZE
Definition: pixfmt.h:32
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
KmvcContext::avctx
AVCodecContext * avctx
Definition: kmvc.c:44
BitBuf
Definition: kmvc.c:54
BLK
#define BLK(data, x, y)
Definition: kmvc.c:59
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1965
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:981
AVPacket::size
int size
Definition: avcodec.h:1478
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:188
val
const char const char void * val
Definition: avisynth_c.h:863
header
static const uint8_t header[24]
Definition: sdr2.c:67
MAX_PALSIZE
#define MAX_PALSIZE
Definition: kmvc.c:38
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
kmvc_init_getbits
#define kmvc_init_getbits(bb, g)
Definition: kmvc.c:61
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1666
common.h
uint8_t
uint8_t
Definition: audio_convert.c:194
AVCodec::name
const char * name
Name of the codec implementation.
Definition: avcodec.h:3488
AVCodecContext::height
int height
Definition: avcodec.h:1738
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1775
avcodec.h
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
ret
ret
Definition: filter_design.txt:187
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
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:88
decode_frame
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: kmvc.c:262
KmvcContext::pal
uint32_t pal[MAX_PALSIZE]
Definition: kmvc.c:48
AVCodecContext
main external API structure.
Definition: avcodec.h:1565
KmvcContext::frm1
uint8_t frm1[320 *200]
Definition: kmvc.c:50
BitBuf::bitbuf
int bitbuf
Definition: kmvc.c:56
KmvcContext::setpal
int setpal
Definition: kmvc.c:46
BitBuf::bits
int bits
Definition: kmvc.c:55
KmvcContext::g
GetByteContext g
Definition: kmvc.c:51
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:275
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:1592
AVPacket
This structure stores compressed data.
Definition: avcodec.h:1454
kmvc_decode_inter_8x8
static int kmvc_decode_inter_8x8(KmvcContext *ctx, int w, int h)
Definition: kmvc.c:162
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:1738
bytestream.h
bytestream2_init
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:133
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: kmvc.c:373
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
h
h
Definition: vp9dsp_template.c:2038
KMVC_PALETTE
#define KMVC_PALETTE
Definition: kmvc.c:36