FFmpeg
cri.c
Go to the documentation of this file.
1 /*
2  * CRI image decoder
3  *
4  * Copyright (c) 2020 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 /**
24  * @file
25  * Cintel RAW image decoder
26  */
27 
28 #define BITSTREAM_READER_LE
29 
30 #include "libavutil/intfloat.h"
31 #include "libavutil/display.h"
32 #include "avcodec.h"
33 #include "bytestream.h"
34 #include "codec_internal.h"
35 #include "decode.h"
36 #include "get_bits.h"
37 #include "thread.h"
38 
39 typedef struct CRIContext {
40  AVCodecContext *jpeg_avctx; // wrapper context for MJPEG
41  AVPacket *jpkt; // encoded JPEG tile
42  AVFrame *jpgframe; // decoded JPEG tile
43 
46  const uint8_t *data;
47  unsigned data_size;
48  uint64_t tile_size[4];
49 } CRIContext;
50 
52 {
53  CRIContext *s = avctx->priv_data;
54  const AVCodec *codec;
55  int ret;
56 
57  s->jpgframe = av_frame_alloc();
58  if (!s->jpgframe)
59  return AVERROR(ENOMEM);
60 
61  s->jpkt = av_packet_alloc();
62  if (!s->jpkt)
63  return AVERROR(ENOMEM);
64 
66  if (!codec)
67  return AVERROR_BUG;
68  s->jpeg_avctx = avcodec_alloc_context3(codec);
69  if (!s->jpeg_avctx)
70  return AVERROR(ENOMEM);
71  s->jpeg_avctx->flags = avctx->flags;
72  s->jpeg_avctx->flags2 = avctx->flags2;
73  s->jpeg_avctx->dct_algo = avctx->dct_algo;
74  s->jpeg_avctx->idct_algo = avctx->idct_algo;
75  ret = avcodec_open2(s->jpeg_avctx, codec, NULL);
76  if (ret < 0)
77  return ret;
78 
79  return 0;
80 }
81 
82 static void unpack_10bit(GetByteContext *gb, uint16_t *dst, int shift,
83  int w, int h, ptrdiff_t stride)
84 {
85  int count = w * h;
86  int pos = 0;
87 
88  while (count > 0) {
89  uint32_t a0, a1, a2, a3;
90  if (bytestream2_get_bytes_left(gb) < 4)
91  break;
92  a0 = bytestream2_get_le32(gb);
93  a1 = bytestream2_get_le32(gb);
94  a2 = bytestream2_get_le32(gb);
95  a3 = bytestream2_get_le32(gb);
96  dst[pos] = (((a0 >> 1) & 0xE00) | (a0 & 0x1FF)) << shift;
97  pos++;
98  if (pos >= w) {
99  if (count == 1)
100  break;
101  dst += stride;
102  pos = 0;
103  }
104  dst[pos] = (((a0 >> 13) & 0x3F) | ((a0 >> 14) & 0xFC0)) << shift;
105  pos++;
106  if (pos >= w) {
107  if (count == 2)
108  break;
109  dst += stride;
110  pos = 0;
111  }
112  dst[pos] = (((a0 >> 26) & 7) | ((a1 & 0x1FF) << 3)) << shift;
113  pos++;
114  if (pos >= w) {
115  if (count == 3)
116  break;
117  dst += stride;
118  pos = 0;
119  }
120  dst[pos] = (((a1 >> 10) & 0x1FF) | ((a1 >> 11) & 0xE00)) << shift;
121  pos++;
122  if (pos >= w) {
123  if (count == 4)
124  break;
125  dst += stride;
126  pos = 0;
127  }
128  dst[pos] = (((a1 >> 23) & 0x3F) | ((a2 & 0x3F) << 6)) << shift;
129  pos++;
130  if (pos >= w) {
131  if (count == 5)
132  break;
133  dst += stride;
134  pos = 0;
135  }
136  dst[pos] = (((a2 >> 7) & 0xFF8) | ((a2 >> 6) & 7)) << shift;
137  pos++;
138  if (pos >= w) {
139  if (count == 6)
140  break;
141  dst += stride;
142  pos = 0;
143  }
144  dst[pos] = (((a3 & 7) << 9) | ((a2 >> 20) & 0x1FF)) << shift;
145  pos++;
146  if (pos >= w) {
147  if (count == 7)
148  break;
149  dst += stride;
150  pos = 0;
151  }
152  dst[pos] = (((a3 >> 4) & 0xFC0) | ((a3 >> 3) & 0x3F)) << shift;
153  pos++;
154  if (pos >= w) {
155  if (count == 8)
156  break;
157  dst += stride;
158  pos = 0;
159  }
160  dst[pos] = (((a3 >> 16) & 7) | ((a3 >> 17) & 0xFF8)) << shift;
161  pos++;
162  if (pos >= w) {
163  if (count == 9)
164  break;
165  dst += stride;
166  pos = 0;
167  }
168 
169  count -= 9;
170  }
171 }
172 
174  int *got_frame, AVPacket *avpkt)
175 {
176  CRIContext *s = avctx->priv_data;
177  GetByteContext *gb = &s->gb;
178  int ret, bps, hflip = 0, vflip = 0;
179  AVFrameSideData *rotation;
180  int compressed = 0;
181 
182  s->data = NULL;
183  s->data_size = 0;
184 
185  bytestream2_init(gb, avpkt->data, avpkt->size);
186 
187  while (bytestream2_get_bytes_left(gb) > 8) {
188  char codec_name[1024];
189  uint32_t key, length;
190  float framerate;
191  int width, height;
192 
193  key = bytestream2_get_le32(gb);
194  length = bytestream2_get_le32(gb);
195 
196  switch (key) {
197  case 1:
198  if (length != 4)
199  return AVERROR_INVALIDDATA;
200 
201  if (bytestream2_get_le32(gb) != MKTAG('D', 'V', 'C', 'C'))
202  return AVERROR_INVALIDDATA;
203  break;
204  case 100:
205  if (length < 16)
206  return AVERROR_INVALIDDATA;
207  width = bytestream2_get_le32(gb);
208  height = bytestream2_get_le32(gb);
209  s->color_model = bytestream2_get_le32(gb);
210  if (bytestream2_get_le32(gb) != 1)
211  return AVERROR_INVALIDDATA;
212  ret = ff_set_dimensions(avctx, width, height);
213  if (ret < 0)
214  return ret;
215  length -= 16;
216  goto skip;
217  case 101:
218  if (length != 4)
219  return AVERROR_INVALIDDATA;
220 
221  if (bytestream2_get_le32(gb) != 0)
222  return AVERROR_INVALIDDATA;
223  break;
224  case 102:
225  bytestream2_get_buffer(gb, codec_name, FFMIN(length, sizeof(codec_name) - 1));
226  length -= FFMIN(length, sizeof(codec_name) - 1);
227  if (strncmp(codec_name, "cintel_craw", FFMIN(length, sizeof(codec_name) - 1)))
228  return AVERROR_INVALIDDATA;
229  compressed = 1;
230  goto skip;
231  case 103:
232  if (bytestream2_get_bytes_left(gb) < length)
233  return AVERROR_INVALIDDATA;
234  s->data = gb->buffer;
235  s->data_size = length;
236  goto skip;
237  case 105:
238  hflip = bytestream2_get_byte(gb) != 0;
239  length--;
240  goto skip;
241  case 106:
242  vflip = bytestream2_get_byte(gb) != 0;
243  length--;
244  goto skip;
245  case 107:
246  if (length != 4)
247  return AVERROR_INVALIDDATA;
248  framerate = av_int2float(bytestream2_get_le32(gb));
249  avctx->framerate.num = framerate * 1000;
250  avctx->framerate.den = 1000;
251  break;
252  case 119:
253  if (length != 32)
254  return AVERROR_INVALIDDATA;
255 
256  for (int i = 0; i < 4; i++)
257  s->tile_size[i] = bytestream2_get_le64(gb);
258  break;
259  default:
260  av_log(avctx, AV_LOG_DEBUG, "skipping unknown key %u of length %u\n", key, length);
261 skip:
262  bytestream2_skip(gb, length);
263  }
264  }
265 
266  switch (s->color_model) {
267  case 76:
268  case 88:
270  break;
271  case 77:
272  case 89:
274  break;
275  case 78:
276  case 90:
278  break;
279  case 45:
280  case 79:
281  case 91:
283  break;
284  }
285 
286  switch (s->color_model) {
287  case 45:
288  bps = 10;
289  break;
290  case 76:
291  case 77:
292  case 78:
293  case 79:
294  bps = 12;
295  break;
296  case 88:
297  case 89:
298  case 90:
299  case 91:
300  bps = 16;
301  break;
302  default:
303  return AVERROR_INVALIDDATA;
304  }
305 
306  if (compressed) {
307  for (int i = 0; i < 4; i++) {
308  if (s->tile_size[i] >= s->data_size)
309  return AVERROR_INVALIDDATA;
310  }
311 
312  if (s->tile_size[0] + s->tile_size[1] + s->tile_size[2] + s->tile_size[3] !=
313  s->data_size)
314  return AVERROR_INVALIDDATA;
315  }
316 
317  if (!s->data || !s->data_size)
318  return AVERROR_INVALIDDATA;
319 
320  if (avctx->skip_frame >= AVDISCARD_ALL)
321  return avpkt->size;
322 
323  if ((ret = ff_thread_get_buffer(avctx, p, 0)) < 0)
324  return ret;
325 
326  avctx->bits_per_raw_sample = bps;
327 
328  if (!compressed && s->color_model == 45) {
329  uint16_t *dst = (uint16_t *)p->data[0];
330  GetByteContext gb;
331 
332  bytestream2_init(&gb, s->data, s->data_size);
333  unpack_10bit(&gb, dst, 4, avctx->width, avctx->height, p->linesize[0] / 2);
334  } else if (!compressed) {
335  GetBitContext gbit;
336  const int shift = 16 - bps;
337 
338  ret = init_get_bits8(&gbit, s->data, s->data_size);
339  if (ret < 0)
340  return ret;
341 
342  for (int y = 0; y < avctx->height; y++) {
343  uint16_t *dst = (uint16_t *)(p->data[0] + y * p->linesize[0]);
344 
345  if (get_bits_left(&gbit) < avctx->width * bps)
346  break;
347 
348  for (int x = 0; x < avctx->width; x++)
349  dst[x] = get_bits(&gbit, bps) << shift;
350  }
351  } else {
352  unsigned offset = 0;
353 
354  for (int tile = 0; tile < 4; tile++) {
355  av_packet_unref(s->jpkt);
356  s->jpkt->data = (uint8_t *)s->data + offset;
357  s->jpkt->size = s->tile_size[tile];
358 
359  ret = avcodec_send_packet(s->jpeg_avctx, s->jpkt);
360  if (ret < 0) {
361  av_log(avctx, AV_LOG_ERROR, "Error submitting a packet for decoding\n");
362  return ret;
363  }
364 
365  ret = avcodec_receive_frame(s->jpeg_avctx, s->jpgframe);
366  if (ret < 0 || s->jpgframe->format != AV_PIX_FMT_GRAY16 ||
367  s->jpeg_avctx->width * 2 != avctx->width ||
368  s->jpeg_avctx->height * 2 != avctx->height) {
369  if (ret < 0) {
370  av_log(avctx, AV_LOG_ERROR,
371  "JPEG decoding error (%d).\n", ret);
372  } else {
373  av_log(avctx, AV_LOG_ERROR,
374  "JPEG invalid format.\n");
376  }
377 
378  /* Normally skip, if error explode */
379  if (avctx->err_recognition & AV_EF_EXPLODE)
380  return ret;
381  else
382  return 0;
383  }
384 
385  for (int y = 0; y < s->jpeg_avctx->height; y++) {
386  const int hw = s->jpgframe->width / 2;
387  uint16_t *dst = (uint16_t *)(p->data[0] + (y * 2) * p->linesize[0] + tile * hw * 2);
388  const uint16_t *src = (const uint16_t *)(s->jpgframe->data[0] + y * s->jpgframe->linesize[0]);
389 
390  memcpy(dst, src, hw * 2);
391  src += hw;
392  dst += p->linesize[0] / 2;
393  memcpy(dst, src, hw * 2);
394  }
395 
396  av_frame_unref(s->jpgframe);
397  offset += s->tile_size[tile];
398  }
399  }
400 
401  if (hflip || vflip) {
403  sizeof(int32_t) * 9);
404  if (rotation) {
405  av_display_rotation_set((int32_t *)rotation->data, 0.f);
406  av_display_matrix_flip((int32_t *)rotation->data, hflip, vflip);
407  }
408  }
409 
411  p->flags |= AV_FRAME_FLAG_KEY;
412 
413  *got_frame = 1;
414 
415  return 0;
416 }
417 
419 {
420  CRIContext *s = avctx->priv_data;
421 
422  av_frame_free(&s->jpgframe);
423  av_packet_free(&s->jpkt);
424  avcodec_free_context(&s->jpeg_avctx);
425 
426  return 0;
427 }
428 
430  .p.name = "cri",
431  .p.type = AVMEDIA_TYPE_VIDEO,
432  .p.id = AV_CODEC_ID_CRI,
433  .priv_data_size = sizeof(CRIContext),
436  .close = cri_decode_close,
437  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
438  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP |
440  CODEC_LONG_NAME("Cintel RAW"),
441 };
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:423
AVCodec
AVCodec.
Definition: codec.h:187
AV_EF_EXPLODE
#define AV_EF_EXPLODE
abort decoding on minor error detection
Definition: defs.h:51
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
CRIContext::data
const uint8_t * data
Definition: cri.c:46
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:694
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
av_frame_new_side_data
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, size_t size)
Add a new side data to a frame.
Definition: frame.c:812
GetByteContext
Definition: bytestream.h:33
CRIContext
Definition: cri.c:39
unpack_10bit
static void unpack_10bit(GetByteContext *gb, uint16_t *dst, int shift, int w, int h, ptrdiff_t stride)
Definition: cri.c:82
AVCodecContext::err_recognition
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
Definition: avcodec.h:1412
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:100
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
w
uint8_t w
Definition: llviddspenc.c:38
av_display_matrix_flip
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip)
Flip the input matrix horizontally and/or vertically.
Definition: display.c:66
AVPacket::data
uint8_t * data
Definition: packet.h:491
FFCodec
Definition: codec_internal.h:127
av_display_rotation_set
void av_display_rotation_set(int32_t matrix[9], double angle)
Initialize a transformation matrix describing a pure clockwise rotation by the specified angle (in de...
Definition: display.c:51
AV_FRAME_DATA_DISPLAYMATRIX
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: frame.h:85
AVFrame::flags
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition: frame.h:649
CRIContext::jpkt
AVPacket * jpkt
Definition: cri.c:41
intfloat.h
ff_set_dimensions
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
Definition: utils.c:94
AV_PIX_FMT_BAYER_GRBG16
#define AV_PIX_FMT_BAYER_GRBG16
Definition: pixfmt.h:496
thread.h
av_packet_free
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: avpacket.c:74
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:361
ff_thread_get_buffer
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have so the codec calls ff_thread_report set FF_CODEC_CAP_ALLOCATE_PROGRESS in FFCodec caps_internal and use ff_thread_get_buffer() to allocate frames. Otherwise decode directly into the user-supplied frames. Call ff_thread_report_progress() after some part of the current picture has decoded. A good place to put this is where draw_horiz_band() is called - add this if it isn 't called anywhere
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:1803
bytestream2_skip
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:168
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:335
ff_cri_decoder
const FFCodec ff_cri_decoder
Definition: cri.c:429
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AVCodecContext::skip_frame
enum AVDiscard skip_frame
Skip decoding for selected frames.
Definition: avcodec.h:1766
av_int2float
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
Definition: intfloat.h:40
GetBitContext
Definition: get_bits.h:108
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:521
AVCodecContext::dct_algo
int dct_algo
DCT algorithm, see FF_DCT_* below.
Definition: avcodec.h:1473
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:452
AVRational::num
int num
Numerator.
Definition: rational.h:59
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:88
a1
#define a1
Definition: regdef.h:47
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
init_get_bits8
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:545
AV_FRAME_FLAG_KEY
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition: frame.h:628
avcodec_alloc_context3
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
Definition: options.c:153
width
#define width
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:306
s
#define s(width, name)
Definition: cbs_vp9.c:198
GetByteContext::buffer
const uint8_t * buffer
Definition: bytestream.h:34
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
CRIContext::tile_size
uint64_t tile_size[4]
Definition: cri.c:48
avcodec_receive_frame
int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder or encoder (when the AV_CODEC_FLAG_RECON_FRAME flag is used...
Definition: avcodec.c:713
cri_decode_init
static av_cold int cri_decode_init(AVCodecContext *avctx)
Definition: cri.c:51
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1517
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
decode.h
get_bits.h
key
const char * key
Definition: hwcontext_opencl.c:174
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
AV_PIX_FMT_BAYER_BGGR16
#define AV_PIX_FMT_BAYER_BGGR16
Definition: pixfmt.h:493
CRIContext::jpeg_avctx
AVCodecContext * jpeg_avctx
Definition: cri.c:40
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:219
framerate
float framerate
Definition: av1_levels.c:29
NULL
#define NULL
Definition: coverity.c:32
avcodec_free_context
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
Definition: options.c:168
CRIContext::jpgframe
AVFrame * jpgframe
Definition: cri.c:42
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:279
AV_PIX_FMT_BAYER_GBRG16
#define AV_PIX_FMT_BAYER_GBRG16
Definition: pixfmt.h:495
bytestream2_get_buffer
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
Definition: bytestream.h:267
avcodec_open2
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
Definition: avcodec.c:128
bytestream2_get_bytes_left
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
Definition: bytestream.h:158
avcodec_find_decoder
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:975
AVCodecContext::flags2
int flags2
AV_CODEC_FLAG2_*.
Definition: avcodec.h:528
AVFrame::pict_type
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:442
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:492
codec_internal.h
shift
static int shift(int a, int b)
Definition: bonk.c:262
bps
unsigned bps
Definition: movenc.c:1738
FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
Definition: codec_internal.h:54
AVFrameSideData::data
uint8_t * data
Definition: frame.h:248
height
#define height
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
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:63
a0
#define a0
Definition: regdef.h:46
AV_CODEC_ID_MJPEG
@ AV_CODEC_ID_MJPEG
Definition: codec_id.h:59
avcodec_send_packet
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
Definition: decode.c:709
AV_CODEC_ID_CRI
@ AV_CODEC_ID_CRI
Definition: codec_id.h:311
CRIContext::data_size
unsigned data_size
Definition: cri.c:47
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
display.h
a2
#define a2
Definition: regdef.h:48
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:622
AVCodecContext::idct_algo
int idct_algo
IDCT algorithm, see FF_IDCT_* below.
Definition: avcodec.h:1486
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
AVCodecContext::height
int height
Definition: avcodec.h:621
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:658
cri_decode_frame
static int cri_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
Definition: cri.c:173
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
AVCodecContext
main external API structure.
Definition: avcodec.h:441
AVRational::den
int den
Denominator.
Definition: rational.h:60
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
CRIContext::color_model
int color_model
Definition: cri.c:45
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:246
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:468
AVPacket
This structure stores compressed data.
Definition: packet.h:468
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:621
int32_t
int32_t
Definition: audioconvert.c:56
bytestream.h
bytestream2_init
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:137
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:385
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
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
h
h
Definition: vp9dsp_template.c:2038
AV_PIX_FMT_BAYER_RGGB16
#define AV_PIX_FMT_BAYER_RGGB16
Definition: pixfmt.h:494
CRIContext::gb
GetByteContext gb
Definition: cri.c:44
a3
#define a3
Definition: regdef.h:49
cri_decode_close
static av_cold int cri_decode_close(AVCodecContext *avctx)
Definition: cri.c:418
skip
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
Definition: bitstream_template.h:375