FFmpeg
prosumer.c
Go to the documentation of this file.
1 /*
2  * Brooktree ProSumer Video decoder
3  * Copyright (c) 2018 Paul B Mahol
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 <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 
26 #include "libavutil/internal.h"
27 #include "libavutil/intreadwrite.h"
28 #include "libavutil/mem.h"
29 
30 #include "avcodec.h"
31 #include "bytestream.h"
32 #include "codec_internal.h"
33 #include "decode.h"
34 
35 typedef struct ProSumerContext {
38 
39  unsigned stride;
40  unsigned size;
41  uint32_t lut[0x2000];
42  uint8_t *initial_line;
43  uint8_t *decbuffer;
45 
46 #define PAIR(high, low) (((uint64_t)(high) << 32) | low)
47 
48 static int decompress(GetByteContext *gb, int size, PutByteContext *pb, const uint32_t *lut)
49 {
50  int pos, idx, cnt, fill;
51  uint32_t a, b, c;
52 
53  bytestream2_skip(gb, 32);
54  cnt = 4;
55  a = bytestream2_get_le32(gb);
56  idx = a >> 20;
57  b = lut[2 * idx];
58 
59  while (1) {
61  return 0;
62  if ((b & 0xFF00u) != 0x8000u || (b & 0xFFu)) {
63  if ((b & 0xFF00u) != 0x8000u) {
64  bytestream2_put_le16(pb, b);
65  } else {
66  idx = 0;
67  for (int i = 0; i < (b & 0xFFu); i++)
68  bytestream2_put_le32(pb, 0);
69  }
70  c = b >> 16;
71  if (c & 0xFF00u) {
72  fill = lut[2 * idx + 1];
73  if ((c & 0xF000u) == 0x1000) {
74  bytestream2_put_le16(pb, fill);
75  } else {
76  bytestream2_put_le32(pb, fill);
77  }
78  c = (c >> 8) & 0x0Fu;
79  }
80  while (c) {
81  a <<= 4;
82  cnt--;
83  if (!cnt) {
84  if (bytestream2_get_bytes_left(gb) <= 0) {
85  if (!a)
86  return 0;
87  } else {
88  pos = bytestream2_tell(gb);
89  bytestream2_seek(gb, pos ^ 2, SEEK_SET);
90  AV_WN16(&a, bytestream2_peek_le16(gb));
91  bytestream2_seek(gb, pos + 2, SEEK_SET);
92  }
93  cnt = 4;
94  }
95  c--;
96  }
97  idx = a >> 20;
98  b = lut[2 * idx];
99  if (!b)
100  return AVERROR_INVALIDDATA;
101  continue;
102  }
103  idx = 2;
104  while (idx) {
105  a <<= 4;
106  cnt--;
107  if (cnt) {
108  idx--;
109  continue;
110  }
111  if (bytestream2_get_bytes_left(gb) <= 0) {
112  if (a) {
113  cnt = 4;
114  idx--;
115  continue;
116  }
117  return 0;
118  }
119  pos = bytestream2_tell(gb);
120  bytestream2_seek(gb, pos ^ 2, SEEK_SET);
121  AV_WN16(&a, bytestream2_peek_le16(gb));
122  bytestream2_seek(gb, pos + 2, SEEK_SET);
123  cnt = 4;
124  idx--;
125  }
126  b = PAIR(4, a) >> 16;
127  }
128 
129  return 0;
130 }
131 
132 static void vertical_predict(uint32_t *dst, int offset, const uint32_t *src, int stride, int height)
133 {
134  dst += offset >> 2;
135 
136  for (int i = 0; i < height; i++) {
137  for (int j = 0; j < stride >> 2; j++) {
138  dst[j] = (((src[j] >> 3) + (0x3F3F3F3F & dst[j])) << 3) & 0xFCFCFCFC;
139  }
140 
141  dst += stride >> 2;
142  src += stride >> 2;
143  }
144 }
145 
147  int *got_frame, AVPacket *avpkt)
148 {
149  ProSumerContext *s = avctx->priv_data;
150  int ret;
151 
152  if (avpkt->size <= 32)
153  return AVERROR_INVALIDDATA;
154 
155  bytestream2_init(&s->gb, avpkt->data, avpkt->size);
156  bytestream2_init_writer(&s->pb, s->decbuffer, s->size);
157  ret = decompress(&s->gb, AV_RL32(avpkt->data + 28) >> 1, &s->pb, s->lut);
158  if (ret < 0)
159  return ret;
160  if (bytestream2_get_bytes_left_p(&s->pb) > s->size * (int64_t)avctx->discard_damaged_percentage / 100)
161  return AVERROR_INVALIDDATA;
162 
163  av_assert0(s->size >= bytestream2_get_bytes_left_p(&s->pb));
164  memset(s->decbuffer + bytestream2_tell_p(&s->pb), 0, bytestream2_get_bytes_left_p(&s->pb));
165 
166  vertical_predict((uint32_t *)s->decbuffer, 0, (uint32_t *)s->initial_line, s->stride, 1);
167  vertical_predict((uint32_t *)s->decbuffer, s->stride, (uint32_t *)s->decbuffer, s->stride, avctx->height - 1);
168 
169  ret = ff_get_buffer(avctx, frame, 0);
170  if (ret < 0)
171  return ret;
172 
173  for (int i = avctx->height - 1; i >= 0 ; i--) {
174  uint8_t *y = &frame->data[0][i * frame->linesize[0]];
175  uint8_t *u = &frame->data[1][i * frame->linesize[1]];
176  uint8_t *v = &frame->data[2][i * frame->linesize[2]];
177  const uint8_t *src = s->decbuffer + (avctx->height - 1 - i) * s->stride;
178 
179  for (int j = 0; j < avctx->width; j += 8) {
180  *(u++) = *src++;
181  *(y++) = *src++;
182  *(v++) = *src++;
183  *(y++) = *src++;
184 
185  *(u++) = *src++;
186  *(y++) = *src++;
187  *(v++) = *src++;
188  *(y++) = *src++;
189 
190  *(y++) = *src++;
191  *(y++) = *src++;
192  *(y++) = *src++;
193  *(y++) = *src++;
194  }
195  }
196 
199  *got_frame = 1;
200 
201  return avpkt->size;
202 }
203 
204 #define TB(i) (1 + ((i) > 10) + ((i) > 49))
205 static const uint16_t table[] = {
206  0x0000, 0x100, 0x0101, 0x200, 0x0202, 0x300, 0xFFFF, 0x400, 0xFEFE, 0x500,
207  0x0001, 0x700, 0x0100, 0x800, 0x00FF, 0x900, 0xFF00, 0xA00, 0x8001, 0x600,
208  0x8002, 0xB00, 0xFCFC, 0x010, 0x0404, 0x030, 0x0002, 0xD30, 0xFEFC, 0x020,
209  0xFCFE, 0x040, 0xFEFF, 0xD20, 0x0808, 0x060, 0xFFFE, 0x050, 0x0402, 0xC00,
210  0x0204, 0xC10, 0xF8F8, 0xC30, 0x0201, 0xC40, 0x0102, 0xC60, 0x0804, 0xF30,
211  0x0408, 0xE00, 0xF8FC, 0xE10, 0xFCF8, 0xC70, 0x00FE, 0xD00, 0xFE00, 0xD40,
212  0xFF01, 0xD50, 0x01FF, 0xD60, 0x0200, 0xD70, 0xFCFF, 0xE20, 0x0104, 0xE30,
213  0xF0F0, 0xE50, 0x0401, 0xE70, 0x02FE, 0xF00, 0xFE02, 0xF10, 0xFE01, 0xF20,
214  0x01FE, 0xF40, 0xFF02, 0xF50, 0x02FF, 0xF60, 0x8003, 0xC20, 0x8004, 0x070,
215  0x8005, 0xD10, 0x8006, 0xC50, 0x8007, 0xE60, 0x8008, 0xE40, 0x8009, 0xF70,
216  0xFC02, 0x080, 0xFE04, 0x081, 0xFC00, 0x082, 0x02FC, 0x083, 0x1010, 0x084,
217  0x00FC, 0x085, 0x0004, 0x086, 0x0400, 0x087, 0xFFFC, 0x088, 0x1008, 0x089,
218  0x0810, 0x08A, 0x0802, 0x08B, 0x0208, 0x08C, 0xFEF8, 0x08D, 0xFC01, 0x08E,
219  0x04FF, 0x08F, 0xF8FE, 0x090, 0xFC04, 0x091, 0x04FC, 0x092, 0xFF04, 0x093,
220  0x01FC, 0x094, 0xF0F8, 0x095, 0xF8F0, 0x096, 0x04FE, 0x097, 0xF0FC, 0x098,
221  0x0008, 0x099, 0x08FE, 0x09A, 0x01F8, 0x09B, 0x0800, 0x09C, 0x08FC, 0x09D,
222  0xFE08, 0x09E, 0xFC08, 0x09F, 0xF800, 0x0A0, 0x0108, 0x0A1, 0xF802, 0x0A2,
223  0x0801, 0x0A3, 0x00F8, 0x0A4, 0xF804, 0x0A5, 0xF8FF, 0x0A6, 0xFFF8, 0x0A7,
224  0x04F8, 0x0A8, 0x02F8, 0x0A9, 0x1004, 0x0AA, 0x08F8, 0x0AB, 0xF808, 0x0AC,
225  0x0410, 0x0AD, 0xFF08, 0x0AE, 0x08FF, 0x0AF, 0xFCF0, 0x0B0, 0xF801, 0x0B1,
226  0xE0F0, 0x0B2, 0xF3F3, 0x0B3, 0xF0E0, 0x0B4, 0xFAFA, 0x0B5, 0xF7F7, 0x0B6,
227  0xFEF0, 0x0B7, 0xF0FE, 0x0B8, 0xE9E9, 0x0B9, 0xF9F9, 0x0BA, 0x2020, 0x0BB,
228  0xE0E0, 0x0BC, 0x02F0, 0x0BD, 0x04F0, 0x0BE, 0x2010, 0x0BF, 0xECEC, 0x0C0,
229  0xEFEF, 0x0C1, 0x1020, 0x0C2, 0xF5F5, 0x0C3, 0xF4F4, 0x0C4, 0xEDED, 0x0C5,
230  0xEAEA, 0x0C6, 0xFBFB, 0x0C7, 0x1002, 0x0C8, 0xF2F2, 0x0C9, 0xF6F6, 0x0CA,
231  0xF1F1, 0x0CB, 0xFDFD, 0x0CC, 0x0210, 0x0CD, 0x10FF, 0x0CE, 0xFDFE, 0x0CF,
232  0x10F8, 0x0D0, 0x1000, 0x0D1, 0xF001, 0x0D2, 0x1001, 0x0D3, 0x0010, 0x0D4,
233  0x10FE, 0x0D5, 0xEBEB, 0x0D6, 0xFE10, 0x0D7, 0x0110, 0x0D8, 0xF000, 0x0D9,
234  0x08F0, 0x0DA, 0x01F0, 0x0DB, 0x0303, 0x0DC, 0x00F0, 0x0DD, 0xF002, 0x0DE,
235  0x10FC, 0x0DF, 0xFC10, 0x0E0, 0xF0FF, 0x0E1, 0xEEEE, 0x0E2, 0xF004, 0x0E3,
236  0xFFF0, 0x0E4, 0xF7F8, 0x0E5, 0xF3F2, 0x0E6, 0xF9FA, 0x0E7, 0x0820, 0x0E8,
237  0x0302, 0x0E9, 0xE0F8, 0x0EA, 0x0505, 0x0EB, 0x2008, 0x0EC, 0xE8E8, 0x0ED,
238  0x0403, 0x0EE, 0xFBFC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7, 0xF5F2, 0xCF8, 0xF8F2, 0xCF9,
266  0xF9F1, 0xCFA, 0xF9F2, 0xCFB, 0xFBEF, 0xCFC, 0x00FD, 0xCFD, 0xECEE, 0xCFE,
267  0xF2EF, 0xCFF, 0xF2F8, 0xD80, 0xF5F0, 0xD81, 0xF6F2, 0xD82, 0xFCF7, 0xD83,
268  0xFCF9, 0xD84, 0x0506, 0xD85, 0xEEEC, 0xD86, 0xF0F6, 0xD87, 0xF2F4, 0xD88,
269  0xF6F1, 0xD89, 0xF8F5, 0xD8A, 0xF9F4, 0xD8B, 0xFBF7, 0xD8C, 0x0503, 0xD8D,
270  0xEFEC, 0xD8E, 0xF3F0, 0xD8F, 0xF4F0, 0xD90, 0xF5F3, 0xD91, 0xF6F3, 0xD92,
271  0xF7FA, 0xD93, 0x800A, 0xD94, 0x800B, 0xD95, 0x800C, 0xD96, 0x800D, 0xD97,
272  0x800E, 0xD98, 0x800F, 0xD99, 0x8010, 0xD9A, 0x8011, 0xD9B, 0x8012, 0xD9C,
273  0x8013, 0xD9D, 0x8014, 0xD9E, 0x8015, 0xD9F, 0x8016, 0xDA0, 0x8017, 0xDA1,
274  0x8018, 0xDA2, 0x8019, 0xDA3, 0x801A, 0xDA4, 0x801B, 0xDA5, 0x801C, 0xDA6,
275  0x801D, 0xDA7, 0x801E, 0xDA8, 0x801F, 0xDA9, 0x8020, 0xDAA, 0x8021, 0xDAB,
276  0x8022, 0xDAC, 0x8023, 0xDAD, 0x8024, 0xDAE, 0x8025, 0xDAF, 0x8026, 0xDB0,
277  0x8027, 0xDB1, 0x8028, 0xDB2, 0x8029, 0xDB3, 0x802A, 0xDB4, 0x802B, 0xDB5,
278  0x802C, 0xDB6, 0x802D, 0xDB7, 0x802E, 0xDB8, 0x802F, 0xDB9, 0x80FF, 0xDBA,
279 };
280 
281 static void fill_elements(uint32_t idx, uint32_t shift, uint32_t *e0, uint32_t *e1)
282 {
283  uint32_t b, h = idx << (32 - shift);
284 
285  for (int j = 0; j < 2; j++) {
286  for (int i = 0; i < 43; i++) {
287  b = 4 * TB(i);
288  if (shift >= b && ((h & (0xFFF00000u << (12 - b))) >> 20) == table[2 * i + 1]) {
289  if (table[2 * i] >> 8 == 0x80u) {
290  return;
291  } else {
292  *e0 = (*e0 & 0xFFFFFFu) | (((12 + b - shift) | (0x40u<<j)) << 22);
293  if (j == 0) {
294  *e1 = table[2 * i];
295  shift -= b;
296  h <<= b;
297  } else {
298  *e1 |= (unsigned)table[2 * i] << 16;
299  }
300  break;
301  }
302  }
303  }
304  }
305 }
306 
307 static void fill_lut(uint32_t *lut)
308 {
309  for (int i = 1; i < FF_ARRAY_ELEMS(table); i += 2) {
310  uint32_t a = table[i];
311  uint32_t b = TB(i>>1);
312  uint32_t c, d;
313 
314  c = (b << 16) | table[i-1];
315  d = 4 * (3 - b);
316  if (d <= 0) {
317  lut[2 * a] = c;
318  lut[2 * a + 1] = 0;
319  } else {
320  for (int j = 0; j < 1 << d; j++) {
321  uint32_t f = 0xFFFFFFFFu;
322  c &= 0xFFFFFFu;
323  if ((c & 0xFF00u) != 0x8000u)
324  fill_elements(j, d, &c, &f);
325  lut[2 * a + 2 * j] = c;
326  lut[2 * a + 2 * j + 1] = f;
327  }
328  }
329  }
330 
331  for (int i = 0; i < 32; i += 2) {
332  lut[i ] = 0x68000;
333  lut[i+1] = 0;
334  }
335 }
336 
338 {
339  ProSumerContext *s = avctx->priv_data;
340 
341  s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1;
342  s->size = avctx->height * s->stride;
343 
344  avctx->pix_fmt = AV_PIX_FMT_YUV411P;
345 
346  s->initial_line = av_malloc(s->stride);
347  s->decbuffer = av_malloc(s->size);
348  if (!s->initial_line || !s->decbuffer)
349  return AVERROR(ENOMEM);
350  memset(s->initial_line, 0x80u, s->stride);
351 
352  fill_lut(s->lut);
353 
354  return 0;
355 }
356 
358 {
359  ProSumerContext *s = avctx->priv_data;
360 
361  av_freep(&s->initial_line);
362  av_freep(&s->decbuffer);
363 
364  return 0;
365 }
366 
368  .p.name = "prosumer",
369  CODEC_LONG_NAME("Brooktree ProSumer Video"),
370  .p.type = AVMEDIA_TYPE_VIDEO,
371  .p.id = AV_CODEC_ID_PROSUMER,
372  .priv_data_size = sizeof(ProSumerContext),
373  .init = decode_init,
375  .close = decode_close,
376  .p.capabilities = AV_CODEC_CAP_DR1,
377  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
378 };
ProSumerContext::gb
GetByteContext gb
Definition: prosumer.c:36
ProSumerContext::lut
uint32_t lut[0x2000]
Definition: prosumer.c:41
bytestream2_get_eof
static av_always_inline unsigned int bytestream2_get_eof(PutByteContext *p)
Definition: bytestream.h:332
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
decode_frame
static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
Definition: prosumer.c:146
GetByteContext
Definition: bytestream.h:33
u
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:250
int64_t
long long int64_t
Definition: coverity.c:34
ProSumerContext::size
unsigned size
Definition: prosumer.c:40
fill_elements
static void fill_elements(uint32_t idx, uint32_t shift, uint32_t *e0, uint32_t *e1)
Definition: prosumer.c:281
fill_lut
static void fill_lut(uint32_t *lut)
Definition: prosumer.c:307
ProSumerContext::initial_line
uint8_t * initial_line
Definition: prosumer.c:42
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
bytestream2_seek
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
Definition: bytestream.h:212
AVPacket::data
uint8_t * data
Definition: packet.h:522
b
#define b
Definition: input.c:41
table
static const uint16_t table[]
Definition: prosumer.c:205
bytestream2_tell_p
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
Definition: bytestream.h:197
PAIR
#define PAIR(high, low)
Definition: prosumer.c:46
FFCodec
Definition: codec_internal.h:127
AVFrame::flags
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition: frame.h:616
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
decompress
static int decompress(GetByteContext *gb, int size, PutByteContext *pb, const uint32_t *lut)
Definition: prosumer.c:48
bytestream2_skip
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:168
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
ProSumerContext
Definition: prosumer.c:35
bytestream2_get_bytes_left_p
static av_always_inline int bytestream2_get_bytes_left_p(PutByteContext *p)
Definition: bytestream.h:163
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
AV_FRAME_FLAG_KEY
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition: frame.h:595
bytestream2_init_writer
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
Definition: bytestream.h:147
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:287
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:198
ProSumerContext::decbuffer
uint8_t * decbuffer
Definition: prosumer.c:43
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
decode.h
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
frame
static AVFrame * frame
Definition: demux_decode.c:54
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:279
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
bytestream2_get_bytes_left
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
Definition: bytestream.h:158
bytestream2_tell
static av_always_inline int bytestream2_tell(GetByteContext *g)
Definition: bytestream.h:192
PutByteContext
Definition: bytestream.h:37
vertical_predict
static void vertical_predict(uint32_t *dst, int offset, const uint32_t *src, int stride, int height)
Definition: prosumer.c:132
f
f
Definition: af_crystalizer.c:121
AVFrame::pict_type
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:446
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1569
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:365
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
decode_close
static av_cold int decode_close(AVCodecContext *avctx)
Definition: prosumer.c:357
shift
static int shift(int a, int b)
Definition: bonk.c:262
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
size
int size
Definition: twinvq_data.h:10344
height
#define height
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
offset
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 offset
Definition: writing_filters.txt:86
decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: prosumer.c:337
TB
#define TB(i)
Definition: prosumer.c:204
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
internal.h
ProSumerContext::stride
unsigned stride
Definition: prosumer.c:39
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
AVCodecContext::height
int height
Definition: avcodec.h:618
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:657
avcodec.h
stride
#define stride
Definition: h264pred_template.c:537
ret
ret
Definition: filter_design.txt:187
pos
unsigned int pos
Definition: spdifenc.c:413
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
AV_CODEC_ID_PROSUMER
@ AV_CODEC_ID_PROSUMER
Definition: codec_id.h:288
AVCodecContext
main external API structure.
Definition: avcodec.h:445
ProSumerContext::pb
PutByteContext pb
Definition: prosumer.c:37
ff_prosumer_decoder
const FFCodec ff_prosumer_decoder
Definition: prosumer.c:367
AVCodecContext::discard_damaged_percentage
int discard_damaged_percentage
The percentage of damaged samples to discard a frame.
Definition: avcodec.h:1969
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
mem.h
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:472
AVPacket
This structure stores compressed data.
Definition: packet.h:499
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
d
d
Definition: ffmpeg_filter.c:409
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:618
bytestream.h
bytestream2_init
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:137
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
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
h
h
Definition: vp9dsp_template.c:2038
AV_WN16
#define AV_WN16(p, v)
Definition: intreadwrite.h:370