FFmpeg  4.4.5
fmvc.c
Go to the documentation of this file.
1 /*
2  * FM Screen Capture Codec decoder
3  *
4  * Copyright (c) 2017 Paul B Mahol
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 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 
27 #include "avcodec.h"
28 #include "bytestream.h"
29 #include "internal.h"
30 
31 #define BLOCK_HEIGHT 112u
32 #define BLOCK_WIDTH 84u
33 
34 typedef struct InterBlock {
35  int w, h;
36  int size;
37  int xor;
38 } InterBlock;
39 
40 typedef struct FMVCContext {
44  size_t buffer_size;
46  size_t pbuffer_size;
47  ptrdiff_t stride;
48  int bpp;
49  int yb, xb;
51  unsigned nb_blocks;
52 } FMVCContext;
53 
55 {
56  unsigned repeat = 0, first = 1, opcode = 0;
57  int i, len, pos;
58 
59  while (bytestream2_get_bytes_left(gb) > 0) {
60  GetByteContext gbc;
61 
62  while (bytestream2_get_bytes_left(gb) > 0) {
63  if (first) {
64  first = 0;
65  if (bytestream2_peek_byte(gb) > 17) {
66  len = bytestream2_get_byte(gb) - 17;
67  if (len < 4) {
68  do {
69  bytestream2_put_byte(pb, bytestream2_get_byte(gb));
70  --len;
71  } while (len);
72  opcode = bytestream2_peek_byte(gb);
73  continue;
74  } else {
75  do {
76  bytestream2_put_byte(pb, bytestream2_get_byte(gb));
77  --len;
78  } while (len);
79  opcode = bytestream2_peek_byte(gb);
80  if (opcode < 0x10) {
81  bytestream2_skip(gb, 1);
82  pos = - (opcode >> 2) - 4 * bytestream2_get_byte(gb) - 2049;
83 
85  bytestream2_seek(&gbc, bytestream2_tell_p(pb) + pos, SEEK_SET);
86 
87  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
88  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
89  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
90  len = opcode & 3;
91  if (!len) {
92  repeat = 1;
93  } else {
94  do {
95  bytestream2_put_byte(pb, bytestream2_get_byte(gb));
96  --len;
97  } while (len);
98  opcode = bytestream2_peek_byte(gb);
99  }
100  continue;
101  }
102  }
103  }
104  repeat = 1;
105  }
106  if (repeat) {
107  repeat = 0;
108  opcode = bytestream2_peek_byte(gb);
109  if (opcode < 0x10) {
110  bytestream2_skip(gb, 1);
111  if (!opcode) {
112  if (!bytestream2_peek_byte(gb)) {
113  do {
114  bytestream2_skip(gb, 1);
115  opcode += 255;
116  } while (!bytestream2_peek_byte(gb) && bytestream2_get_bytes_left(gb) > 0);
117  }
118  opcode += bytestream2_get_byte(gb) + 15;
119  }
120  bytestream2_put_le32(pb, bytestream2_get_le32(gb));
121  for (i = opcode - 1; i > 0; --i)
122  bytestream2_put_byte(pb, bytestream2_get_byte(gb));
123  opcode = bytestream2_peek_byte(gb);
124  if (opcode < 0x10) {
125  bytestream2_skip(gb, 1);
126  pos = - (opcode >> 2) - 4 * bytestream2_get_byte(gb) - 2049;
127 
129  bytestream2_seek(&gbc, bytestream2_tell_p(pb) + pos, SEEK_SET);
130 
131  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
132  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
133  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
134  len = opcode & 3;
135  if (!len) {
136  repeat = 1;
137  } else {
138  do {
139  bytestream2_put_byte(pb, bytestream2_get_byte(gb));
140  --len;
141  } while (len);
142  opcode = bytestream2_peek_byte(gb);
143  }
144  continue;
145  }
146  }
147  }
148 
149  if (opcode >= 0x40) {
150  bytestream2_skip(gb, 1);
151  pos = - ((opcode >> 2) & 7) - 1 - 8 * bytestream2_get_byte(gb);
152  len = (opcode >> 5) - 1;
153 
155  bytestream2_seek(&gbc, bytestream2_tell_p(pb) + pos, SEEK_SET);
156 
157  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
158  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
159  do {
160  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
161  --len;
162  } while (len);
163 
164  len = opcode & 3;
165 
166  if (!len) {
167  repeat = 1;
168  } else {
169  do {
170  bytestream2_put_byte(pb, bytestream2_get_byte(gb));
171  --len;
172  } while (len);
173  opcode = bytestream2_peek_byte(gb);
174  }
175  continue;
176  } else if (opcode < 0x20) {
177  break;
178  }
179  len = opcode & 0x1F;
180  bytestream2_skip(gb, 1);
181  if (!len) {
182  if (!bytestream2_peek_byte(gb)) {
183  do {
184  bytestream2_skip(gb, 1);
185  len += 255;
186  } while (!bytestream2_peek_byte(gb) && bytestream2_get_bytes_left(gb) > 0);
187  }
188  len += bytestream2_get_byte(gb) + 31;
189  }
190  i = bytestream2_get_le16(gb);
191  pos = - (i >> 2) - 1;
192 
194  bytestream2_seek(&gbc, bytestream2_tell_p(pb) + pos, SEEK_SET);
195 
196  if (len < 6 || bytestream2_tell_p(pb) - bytestream2_tell(&gbc) < 4) {
197  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
198  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
199  do {
200  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
201  --len;
202  } while (len);
203  } else {
204  bytestream2_put_le32(pb, bytestream2_get_le32(&gbc));
205  for (len = len - 2; len; --len)
206  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
207  }
208  len = i & 3;
209  if (!len) {
210  repeat = 1;
211  } else {
212  do {
213  bytestream2_put_byte(pb, bytestream2_get_byte(gb));
214  --len;
215  } while (len);
216  opcode = bytestream2_peek_byte(gb);
217  }
218  }
219  bytestream2_skip(gb, 1);
220  if (opcode < 0x10) {
221  pos = -(opcode >> 2) - 1 - 4 * bytestream2_get_byte(gb);
222 
224  bytestream2_seek(&gbc, bytestream2_tell_p(pb) + pos, SEEK_SET);
225 
226  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
227  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
228  len = opcode & 3;
229  if (!len) {
230  repeat = 1;
231  } else {
232  do {
233  bytestream2_put_byte(pb, bytestream2_get_byte(gb));
234  --len;
235  } while (len);
236  opcode = bytestream2_peek_byte(gb);
237  }
238  continue;
239  }
240  len = opcode & 7;
241  if (!len) {
242  if (!bytestream2_peek_byte(gb)) {
243  do {
244  bytestream2_skip(gb, 1);
245  len += 255;
246  } while (!bytestream2_peek_byte(gb) && bytestream2_get_bytes_left(gb) > 0);
247  }
248  len += bytestream2_get_byte(gb) + 7;
249  }
250  i = bytestream2_get_le16(gb);
251  pos = bytestream2_tell_p(pb) - 2048 * (opcode & 8);
252  pos = pos - (i >> 2);
253  if (pos == bytestream2_tell_p(pb))
254  break;
255 
256  pos = pos - 0x4000;
258  bytestream2_seek(&gbc, pos, SEEK_SET);
259 
260  if (len < 6 || bytestream2_tell_p(pb) - bytestream2_tell(&gbc) < 4) {
261  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
262  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
263  do {
264  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
265  --len;
266  } while (len);
267  } else {
268  bytestream2_put_le32(pb, bytestream2_get_le32(&gbc));
269  for (len = len - 2; len; --len)
270  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
271  }
272 
273  len = i & 3;
274  if (!len) {
275  repeat = 1;
276  } else {
277  do {
278  bytestream2_put_byte(pb, bytestream2_get_byte(gb));
279  --len;
280  } while (len);
281  opcode = bytestream2_peek_byte(gb);
282  }
283  }
284 
285  return 0;
286 }
287 
289 {
290  unsigned opcode = 0, len;
291  int high = 0;
292  int i, pos;
293 
294  while (bytestream2_get_bytes_left(gb) > 0) {
295  GetByteContext gbc;
296 
297  while (bytestream2_get_bytes_left(gb) > 0) {
298  while (bytestream2_get_bytes_left(gb) > 0) {
299  opcode = bytestream2_get_byte(gb);
300  high = opcode >= 0x20;
301  if (high)
302  break;
303  if (opcode)
304  break;
305  opcode = bytestream2_get_byte(gb);
306  if (opcode < 0xF8) {
307  opcode += 32;
308  break;
309  }
310  i = opcode - 0xF8;
311  if (i) {
312  len = 256;
313  do {
314  len *= 2;
315  --i;
316  } while (i);
317  } else {
318  len = 280;
319  }
320  do {
321  bytestream2_put_le32(pb, bytestream2_get_le32(gb));
322  bytestream2_put_le32(pb, bytestream2_get_le32(gb));
323  len -= 8;
324  } while (len && bytestream2_get_bytes_left(gb) > 0);
325  }
326 
327  if (!high) {
328  do {
329  bytestream2_put_byte(pb, bytestream2_get_byte(gb));
330  --opcode;
331  } while (opcode && bytestream2_get_bytes_left(gb) > 0);
332 
333  while (bytestream2_get_bytes_left(gb) > 0) {
334  GetByteContext gbc;
335 
336  opcode = bytestream2_get_byte(gb);
337  if (opcode >= 0x20)
338  break;
340 
341  pos = -(opcode | 32 * bytestream2_get_byte(gb)) - 1;
342  bytestream2_seek(&gbc, bytestream2_tell_p(pb) + pos, SEEK_SET);
343  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
344  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
345  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
346  bytestream2_put_byte(pb, bytestream2_get_byte(gb));
347  }
348  }
349  high = 0;
350  if (opcode < 0x40)
351  break;
353  pos = (-((opcode & 0x1F) | 32 * bytestream2_get_byte(gb)) - 1);
354  bytestream2_seek(&gbc, bytestream2_tell_p(pb) + pos, SEEK_SET);
355  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
356  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
357  len = (opcode >> 5) - 1;
358  do {
359  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
360  --len;
361  } while (len && bytestream2_get_bytes_left(&gbc) > 0);
362  }
363  len = opcode & 0x1F;
364  if (!len) {
365  if (!bytestream2_peek_byte(gb)) {
366  do {
367  bytestream2_skip(gb, 1);
368  len += 255;
369  } while (!bytestream2_peek_byte(gb) && bytestream2_get_bytes_left(gb) > 0);
370  }
371  len += bytestream2_get_byte(gb) + 31;
372  }
373  pos = -bytestream2_get_byte(gb);
375  bytestream2_seek(&gbc, bytestream2_tell_p(pb) + pos - (bytestream2_get_byte(gb) << 8), SEEK_SET);
376  if (bytestream2_tell_p(pb) == bytestream2_tell(&gbc))
377  break;
378  if (len < 5 || bytestream2_tell_p(pb) - bytestream2_tell(&gbc) < 4) {
379  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
380  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
381  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
382  } else {
383  bytestream2_put_le32(pb, bytestream2_get_le32(&gbc));
384  len--;
385  }
386  do {
387  bytestream2_put_byte(pb, bytestream2_get_byte(&gbc));
388  len--;
389  } while (len && bytestream2_get_bytes_left(&gbc) > 0);
390  }
391 
392  return 0;
393 }
394 
395 static int decode_frame(AVCodecContext *avctx, void *data,
396  int *got_frame, AVPacket *avpkt)
397 {
398  FMVCContext *s = avctx->priv_data;
399  GetByteContext *gb = &s->gb;
400  PutByteContext *pb = &s->pb;
401  AVFrame *frame = data;
402  int ret, y, x;
403  int key_frame;
404 
405  if (avpkt->size < 8)
406  return AVERROR_INVALIDDATA;
407 
408  bytestream2_init(gb, avpkt->data, avpkt->size);
409  bytestream2_skip(gb, 2);
410 
411  key_frame = !!bytestream2_get_le16(gb);
412 
413  if (key_frame) {
414  const uint8_t *src;
415  unsigned type, size;
416  uint8_t *dst;
417 
418  type = bytestream2_get_le16(gb);
419  size = bytestream2_get_le16(gb);
421  return AVERROR_INVALIDDATA;
422 
423  bytestream2_init_writer(pb, s->buffer, s->buffer_size);
424  if (type == 1) {
425  decode_type1(gb, pb);
426  } else if (type == 2){
427  decode_type2(gb, pb);
428  } else {
429  avpriv_report_missing_feature(avctx, "Compression type %d", type);
430  return AVERROR_PATCHWELCOME;
431  }
432 
433  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
434  return ret;
435 
436  frame->key_frame = 1;
438 
439  src = s->buffer;
440  dst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
441  for (y = 0; y < avctx->height; y++) {
442  memcpy(dst, src, avctx->width * s->bpp);
443  dst -= frame->linesize[0];
444  src += s->stride * 4;
445  if (bytestream2_tell_p(pb) < y*s->stride * 4)
446  break;
447  }
448  } else {
449  unsigned block, nb_blocks;
450  int type, k, l;
451  uint8_t *ssrc, *ddst;
452  const uint32_t *src;
453  uint32_t *dst;
454 
455  for (block = 0; block < s->nb_blocks; block++)
456  s->blocks[block].xor = 0;
457 
458  nb_blocks = bytestream2_get_le16(gb);
459  if (nb_blocks > s->nb_blocks)
460  return AVERROR_INVALIDDATA;
461 
462  bytestream2_init_writer(pb, s->pbuffer, s->pbuffer_size);
463 
464  type = bytestream2_get_le16(gb);
465  for (block = 0; block < nb_blocks; block++) {
466  unsigned size, offset;
467  int start = 0;
468 
469  offset = bytestream2_get_le16(gb);
470  if (offset >= s->nb_blocks)
471  return AVERROR_INVALIDDATA;
472 
473  size = bytestream2_get_le16(gb);
475  return AVERROR_INVALIDDATA;
476 
477  start = bytestream2_tell_p(pb);
478  if (type == 1) {
479  decode_type1(gb, pb);
480  } else if (type == 2){
481  decode_type2(gb, pb);
482  } else {
483  avpriv_report_missing_feature(avctx, "Compression type %d", type);
484  return AVERROR_PATCHWELCOME;
485  }
486 
487  if (s->blocks[offset].size * 4 != bytestream2_tell_p(pb) - start)
488  return AVERROR_INVALIDDATA;
489 
490  s->blocks[offset].xor = 1;
491  }
492 
493  src = (const uint32_t *)s->pbuffer;
494  dst = (uint32_t *)s->buffer;
495 
496  for (block = 0, y = 0; y < s->yb; y++) {
497  int block_h = s->blocks[block].h;
498  uint32_t *rect = dst;
499 
500  for (x = 0; x < s->xb; x++) {
501  int block_w = s->blocks[block].w;
502  uint32_t *row = dst;
503 
504  block_h = s->blocks[block].h;
505  if (s->blocks[block].xor) {
506  for (k = 0; k < block_h; k++) {
507  uint32_t *column = dst;
508  for (l = 0; l < block_w; l++)
509  *dst++ ^= *src++;
510  dst = &column[s->stride];
511  }
512  }
513  dst = &row[block_w];
514  ++block;
515  }
516  dst = &rect[block_h * s->stride];
517  }
518 
519  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
520  return ret;
521 
522  frame->key_frame = 0;
524 
525  ssrc = s->buffer;
526  ddst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
527  for (y = 0; y < avctx->height; y++) {
528  memcpy(ddst, ssrc, avctx->width * s->bpp);
529  ddst -= frame->linesize[0];
530  ssrc += s->stride * 4;
531  }
532  }
533 
534  *got_frame = 1;
535 
536  return avpkt->size;
537 }
538 
540 {
541  FMVCContext *s = avctx->priv_data;
542  int i, j, m, block = 0, h = BLOCK_HEIGHT, w = BLOCK_WIDTH;
543 
544  switch (avctx->bits_per_coded_sample) {
545  case 16:
546  avctx->pix_fmt = AV_PIX_FMT_RGB555LE;
547  break;
548  case 24:
549  avctx->pix_fmt = AV_PIX_FMT_BGR24;
550  break;
551  case 32:
552  avctx->pix_fmt = AV_PIX_FMT_BGRA;
553  break;
554  default:
555  av_log(avctx, AV_LOG_ERROR, "Unsupported bitdepth %i\n",
556  avctx->bits_per_coded_sample);
557  return AVERROR_INVALIDDATA;
558  }
559 
560  s->stride = (avctx->width * avctx->bits_per_coded_sample + 31) / 32;
561  s->xb = s->stride / BLOCK_WIDTH;
562  m = s->stride % BLOCK_WIDTH;
563  if (m) {
564  if (m < 37) {
565  w = m + BLOCK_WIDTH;
566  } else {
567  w = m;
568  s->xb++;
569  }
570  }
571 
572  s->yb = avctx->height / BLOCK_HEIGHT;
573  m = avctx->height % BLOCK_HEIGHT;
574  if (m) {
575  if (m < 49) {
576  h = m + BLOCK_HEIGHT;
577  } else {
578  h = m;
579  s->yb++;
580  }
581  }
582 
583  s->nb_blocks = s->xb * s->yb;
584  if (!s->nb_blocks)
585  return AVERROR_INVALIDDATA;
586  s->blocks = av_calloc(s->nb_blocks, sizeof(*s->blocks));
587  if (!s->blocks)
588  return AVERROR(ENOMEM);
589 
590  for (i = 0; i < s->yb; i++) {
591  for (j = 0; j < s->xb; j++) {
592  if (i != (s->yb - 1) || j != (s->xb - 1)) {
593  if (i == s->yb - 1) {
594  s->blocks[block].w = BLOCK_WIDTH;
595  s->blocks[block].h = h;
596  s->blocks[block].size = BLOCK_WIDTH * h;
597  } else if (j == s->xb - 1) {
598  s->blocks[block].w = w;
599  s->blocks[block].h = BLOCK_HEIGHT;
600  s->blocks[block].size = BLOCK_HEIGHT * w;
601  } else {
602  s->blocks[block].w = BLOCK_WIDTH;
603  s->blocks[block].h = BLOCK_HEIGHT;
604  s->blocks[block].size = BLOCK_WIDTH * BLOCK_HEIGHT;
605  }
606  } else {
607  s->blocks[block].w = w;
608  s->blocks[block].h = h;
609  s->blocks[block].size = w * h;
610  }
611  block++;
612  }
613  }
614 
615  s->bpp = avctx->bits_per_coded_sample >> 3;
616  s->buffer_size = avctx->width * avctx->height * 4;
617  s->pbuffer_size = avctx->width * avctx->height * 4;
618  s->buffer = av_mallocz(s->buffer_size);
619  s->pbuffer = av_mallocz(s->pbuffer_size);
620  if (!s->buffer || !s->pbuffer)
621  return AVERROR(ENOMEM);
622 
623  return 0;
624 }
625 
627 {
628  FMVCContext *s = avctx->priv_data;
629 
630  av_freep(&s->buffer);
631  av_freep(&s->pbuffer);
632  av_freep(&s->blocks);
633 
634  return 0;
635 }
636 
638  .name = "fmvc",
639  .long_name = NULL_IF_CONFIG_SMALL("FM Screen Capture Codec"),
640  .type = AVMEDIA_TYPE_VIDEO,
641  .id = AV_CODEC_ID_FMVC,
642  .priv_data_size = sizeof(FMVCContext),
643  .init = decode_init,
644  .close = decode_close,
645  .decode = decode_frame,
646  .capabilities = AV_CODEC_CAP_DR1,
647  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
649 };
#define av_cold
Definition: attributes.h:88
uint8_t
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
Definition: bytestream.h:147
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
Definition: bytestream.h:197
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 void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:168
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
Definition: bytestream.h:212
static av_always_inline int bytestream2_tell(GetByteContext *g)
Definition: bytestream.h:192
#define s(width, name)
Definition: cbs_vp9.c:257
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1900
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
static AVFrame * frame
static av_cold int decode_close(AVCodecContext *avctx)
Definition: fmvc.c:626
static int decode_type2(GetByteContext *gb, PutByteContext *pb)
Definition: fmvc.c:54
static av_cold int decode_init(AVCodecContext *avctx)
Definition: fmvc.c:539
AVCodec ff_fmvc_decoder
Definition: fmvc.c:637
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: fmvc.c:395
#define BLOCK_HEIGHT
Definition: fmvc.c:31
static int decode_type1(GetByteContext *gb, PutByteContext *pb)
Definition: fmvc.c:288
#define BLOCK_WIDTH
Definition: fmvc.c:32
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
@ AV_CODEC_ID_FMVC
Definition: codec_id.h:275
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
#define AVERROR(e)
Definition: error.h:43
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:237
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:245
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:275
for(j=16;j >0;--j)
cl_device_type type
int i
Definition: input.c:407
#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
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
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint8_t w
Definition: llviddspenc.c:39
const char data[16]
Definition: mxf.c:142
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
@ AV_PIX_FMT_RGB555LE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined
Definition: pixfmt.h:108
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
unsigned int pos
Definition: spdifenc.c:412
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
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1740
void * priv_data
Definition: avcodec.h:563
AVCodec.
Definition: codec.h:197
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
uint8_t * pbuffer
Definition: fmvc.c:45
PutByteContext pb
Definition: fmvc.c:42
uint8_t * buffer
Definition: fmvc.c:43
size_t buffer_size
Definition: fmvc.c:44
int bpp
Definition: fmvc.c:48
int yb
Definition: fmvc.c:49
GetByteContext gb
Definition: fmvc.c:41
InterBlock * blocks
Definition: fmvc.c:50
unsigned nb_blocks
Definition: fmvc.c:51
size_t pbuffer_size
Definition: fmvc.c:46
int xb
Definition: fmvc.c:49
ptrdiff_t stride
Definition: fmvc.c:47
int size
Definition: fmvc.c:36
int h
Definition: fmvc.c:35
int w
Definition: fmvc.c:35
int xor
Definition: fmvc.c:37
uint8_t * buffer_end
Definition: bytestream.h:38
uint8_t * buffer_start
Definition: bytestream.h:38
Definition: f_ebur128.c:91
#define av_freep(p)
#define av_log(a,...)
#define src
Definition: vp8dsp.c:255
static int16_t block[64]
Definition: dct.c:116
int size
static const uint8_t offset[127][2]
Definition: vf_spp.c:107
int len