FFmpeg  4.4.9
notchlc.c
Go to the documentation of this file.
1 /*
2  * NotchLC decoder
3  * Copyright (c) 2020 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 #define BITSTREAM_READER_LE
27 #include "libavutil/intreadwrite.h"
28 #include "avcodec.h"
29 #include "bytestream.h"
30 #include "get_bits.h"
31 #include "internal.h"
32 #include "lzf.h"
33 #include "thread.h"
34 
35 typedef struct NotchLCContext {
36  unsigned compressed_size;
37  unsigned format;
38 
41 
43  size_t lzf_size;
44  unsigned lzf_alloc_size;
45 
46  unsigned texture_size_x;
47  unsigned texture_size_y;
52  unsigned y_data_offset;
53  unsigned uv_data_offset;
54  unsigned y_data_size;
55  unsigned a_data_offset;
56  unsigned uv_count_offset;
57  unsigned a_count_size;
58  unsigned data_end;
59 
63 
65 {
68  avctx->colorspace = AVCOL_SPC_RGB;
71 
72  return 0;
73 }
74 
75 #define HISTORY_SIZE (64 * 1024)
76 
77 static int lz4_decompress(AVCodecContext *avctx,
78  GetByteContext *gb,
79  PutByteContext *pb)
80 {
81  unsigned reference_pos, match_length, delta, pos = 0;
82  uint8_t history[64 * 1024] = { 0 };
83 
84  while (bytestream2_get_bytes_left(gb) > 0) {
85  uint8_t token = bytestream2_get_byte(gb);
86  unsigned num_literals = token >> 4;
87 
88  if (num_literals == 15) {
89  unsigned char current;
90  do {
91  current = bytestream2_get_byte(gb);
92  if (current > INT_MAX - num_literals)
93  return AVERROR_INVALIDDATA;
94  num_literals += current;
95  } while (current == 255);
96  }
97 
98  if (bytestream2_get_bytes_left(gb) < num_literals)
99  return AVERROR_INVALIDDATA;
100 
101  if (pos + num_literals < HISTORY_SIZE) {
102  bytestream2_get_buffer(gb, history + pos, num_literals);
103  pos += num_literals;
104  } else {
105  while (num_literals-- > 0) {
106  history[pos++] = bytestream2_get_byte(gb);
107  if (pos == HISTORY_SIZE) {
108  bytestream2_put_buffer(pb, history, HISTORY_SIZE);
109  pos = 0;
110  }
111  }
112  }
113 
114  if (bytestream2_get_bytes_left(gb) <= 0)
115  break;
116 
117  delta = bytestream2_get_le16(gb);
118  if (delta == 0)
119  return 0;
120  match_length = 4 + (token & 0x0F);
121  if (match_length == 4 + 0x0F) {
122  uint8_t current;
123 
124  do {
125  current = bytestream2_get_byte(gb);
126  if (current > INT_MAX - match_length)
127  return AVERROR_INVALIDDATA;
128  match_length += current;
129  } while (current == 255);
130  }
131  reference_pos = (pos >= delta) ? (pos - delta) : (HISTORY_SIZE + pos - delta);
132  if (pos + match_length < HISTORY_SIZE && reference_pos + match_length < HISTORY_SIZE) {
133  if (pos >= reference_pos + match_length || reference_pos >= pos + match_length) {
134  memcpy(history + pos, history + reference_pos, match_length);
135  pos += match_length;
136  } else {
137  while (match_length-- > 0)
138  history[pos++] = history[reference_pos++];
139  }
140  } else {
141  while (match_length-- > 0) {
142  history[pos++] = history[reference_pos++];
143  if (pos == HISTORY_SIZE) {
144  bytestream2_put_buffer(pb, history, HISTORY_SIZE);
145  pos = 0;
146  }
147  reference_pos %= HISTORY_SIZE;
148  }
149  }
150  }
151 
152  bytestream2_put_buffer(pb, history, pos);
153 
154  return bytestream2_tell_p(pb);
155 }
156 
158  unsigned uncompressed_size)
159 {
160  NotchLCContext *s = avctx->priv_data;
161  GetByteContext rgb, dgb, *gb = &s->gb;
163  int ylinesize, ulinesize, vlinesize, alinesize;
164  uint16_t *dsty, *dstu, *dstv, *dsta;
165  int ret;
166 
167  s->texture_size_x = bytestream2_get_le32(gb);
168  s->texture_size_y = bytestream2_get_le32(gb);
169 
170  ret = ff_set_dimensions(avctx, s->texture_size_x, s->texture_size_y);
171  if (ret < 0)
172  return ret;
173 
174  s->uv_offset_data_offset = bytestream2_get_le32(gb);
175  if (s->uv_offset_data_offset >= UINT_MAX / 4)
176  return AVERROR_INVALIDDATA;
177  s->uv_offset_data_offset *= 4;
178  if (s->uv_offset_data_offset >= uncompressed_size)
179  return AVERROR_INVALIDDATA;
180 
181  s->y_control_data_offset = bytestream2_get_le32(gb);
182  if (s->y_control_data_offset >= UINT_MAX / 4)
183  return AVERROR_INVALIDDATA;
184  s->y_control_data_offset *= 4;
185  if (s->y_control_data_offset >= uncompressed_size)
186  return AVERROR_INVALIDDATA;
187 
188  s->a_control_word_offset = bytestream2_get_le32(gb);
189  if (s->a_control_word_offset >= UINT_MAX / 4)
190  return AVERROR_INVALIDDATA;
191  s->a_control_word_offset *= 4;
192  if (s->a_control_word_offset >= uncompressed_size)
193  return AVERROR_INVALIDDATA;
194 
195  s->uv_data_offset = bytestream2_get_le32(gb);
196  if (s->uv_data_offset >= UINT_MAX / 4)
197  return AVERROR_INVALIDDATA;
198  s->uv_data_offset *= 4;
199  if (s->uv_data_offset >= uncompressed_size)
200  return AVERROR_INVALIDDATA;
201 
202  s->y_data_size = bytestream2_get_le32(gb);
203  if (s->y_data_size >= UINT_MAX / 4)
204  return AVERROR_INVALIDDATA;
205 
206  s->a_data_offset = bytestream2_get_le32(gb);
207  if (s->a_data_offset >= UINT_MAX / 4)
208  return AVERROR_INVALIDDATA;
209  s->a_data_offset *= 4;
210  if (s->a_data_offset >= uncompressed_size)
211  return AVERROR_INVALIDDATA;
212 
213  s->a_count_size = bytestream2_get_le32(gb);
214  if (s->a_count_size >= UINT_MAX / 4)
215  return AVERROR_INVALIDDATA;
216  s->a_count_size *= 4;
217  if (s->a_count_size >= uncompressed_size)
218  return AVERROR_INVALIDDATA;
219 
220  s->data_end = bytestream2_get_le32(gb);
221  if (s->data_end > uncompressed_size)
222  return AVERROR_INVALIDDATA;
223 
224  s->y_data_row_offsets = bytestream2_tell(gb);
225  if (s->data_end <= s->y_data_size)
226  return AVERROR_INVALIDDATA;
227  s->y_data_offset = s->data_end - s->y_data_size;
228  if (s->y_data_offset <= s->a_data_offset)
229  return AVERROR_INVALIDDATA;
230  s->uv_count_offset = s->y_data_offset - s->a_data_offset;
231 
232  if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
233  return ret;
234 
235  rgb = *gb;
236  dgb = *gb;
237  bytestream2_seek(&rgb, s->y_data_row_offsets, SEEK_SET);
238  bytestream2_seek(gb, s->y_control_data_offset, SEEK_SET);
239 
240  if (bytestream2_get_bytes_left(gb) < (avctx->height + 3) / 4 * ((avctx->width + 3) / 4) * 4)
241  return AVERROR_INVALIDDATA;
242 
243  dsty = (uint16_t *)p->data[0];
244  dsta = (uint16_t *)p->data[3];
245  ylinesize = p->linesize[0] / 2;
246  alinesize = p->linesize[3] / 2;
247 
248  for (int y = 0; y < avctx->height; y += 4) {
249  const unsigned row_offset = bytestream2_get_le32(&rgb);
250 
251  bytestream2_seek(&dgb, s->y_data_offset + row_offset, SEEK_SET);
252 
254  if (ret < 0)
255  return ret;
256  for (int x = 0; x < avctx->width; x += 4) {
257  unsigned item = bytestream2_get_le32(gb);
258  unsigned y_min = item & 4095;
259  unsigned y_max = (item >> 12) & 4095;
260  unsigned y_diff = y_max - y_min;
261  unsigned control[4];
262 
263  control[0] = (item >> 24) & 3;
264  control[1] = (item >> 26) & 3;
265  control[2] = (item >> 28) & 3;
266  control[3] = (item >> 30) & 3;
267 
268  for (int i = 0; i < 4; i++) {
269  const int nb_bits = control[i] + 1;
270  const int div = (1 << nb_bits) - 1;
271  const int add = div - 1;
272 
273  dsty[x + i * ylinesize + 0] = av_clip_uintp2(y_min + ((y_diff * get_bits(&bit, nb_bits) + add) / div), 12);
274  dsty[x + i * ylinesize + 1] = av_clip_uintp2(y_min + ((y_diff * get_bits(&bit, nb_bits) + add) / div), 12);
275  dsty[x + i * ylinesize + 2] = av_clip_uintp2(y_min + ((y_diff * get_bits(&bit, nb_bits) + add) / div), 12);
276  dsty[x + i * ylinesize + 3] = av_clip_uintp2(y_min + ((y_diff * get_bits(&bit, nb_bits) + add) / div), 12);
277  }
278  }
279 
280  dsty += 4 * ylinesize;
281  }
282 
283  rgb = *gb;
284  dgb = *gb;
285  bytestream2_seek(gb, s->a_control_word_offset, SEEK_SET);
286  if (s->uv_count_offset == s->a_control_word_offset) {
287  for (int y = 0; y < avctx->height; y++) {
288  for (int x = 0; x < avctx->width; x++)
289  dsta[x] = 4095;
290  dsta += alinesize;
291  }
292  } else {
293  if (bytestream2_get_bytes_left(gb) < (avctx->height + 15) / 16 * ((avctx->width + 15) / 16) * 8)
294  return AVERROR_INVALIDDATA;
295 
296  for (int y = 0; y < avctx->height; y += 16) {
297  for (int x = 0; x < avctx->width; x += 16) {
298  unsigned m = bytestream2_get_le32(gb);
299  unsigned offset = bytestream2_get_le32(gb);
300  unsigned alpha0, alpha1;
301  uint64_t control;
302 
303  if (offset >= UINT_MAX / 4)
304  return AVERROR_INVALIDDATA;
305  offset = offset * 4 + s->uv_data_offset + s->a_data_offset;
306  if (offset >= s->data_end)
307  return AVERROR_INVALIDDATA;
308 
309  bytestream2_seek(&dgb, offset, SEEK_SET);
310  control = bytestream2_get_le64(&dgb);
311  alpha0 = control & 0xFF;
312  alpha1 = (control >> 8) & 0xFF;
313  control = control >> 16;
314 
315  for (int by = 0; by < 4; by++) {
316  for (int bx = 0; bx < 4; bx++) {
317  switch (m & 3) {
318  case 0:
319  for (int i = 0; i < 4; i++) {
320  for (int j = 0; j < 4; j++) {
321  dsta[x + (i + by * 4) * alinesize + bx * 4 + j] = 0;
322  }
323  }
324  break;
325  case 1:
326  for (int i = 0; i < 4; i++) {
327  for (int j = 0; j < 4; j++) {
328  dsta[x + (i + by * 4) * alinesize + bx * 4 + j] = 4095;
329  }
330  }
331  break;
332  case 2:
333  for (int i = 0; i < 4; i++) {
334  for (int j = 0; j < 4; j++) {
335  dsta[x + (i + by * 4) * alinesize + bx * 4 + j] = (alpha0 + (alpha1 - alpha0) * (control & 7)) << 4;
336  }
337  }
338  break;
339  default:
340  return AVERROR_INVALIDDATA;
341  }
342 
343  control >>= 3;
344  m >>= 2;
345  }
346  }
347  }
348 
349  dsta += 16 * alinesize;
350  }
351  }
352 
353  bytestream2_seek(&rgb, s->uv_offset_data_offset, SEEK_SET);
354 
355  dstu = (uint16_t *)p->data[1];
356  dstv = (uint16_t *)p->data[2];
357  ulinesize = p->linesize[1] / 2;
358  vlinesize = p->linesize[2] / 2;
359 
360  for (int y = 0; y < avctx->height; y += 16) {
361  for (int x = 0; x < avctx->width; x += 16) {
362  unsigned offset = bytestream2_get_le32(&rgb) * 4;
363  int u[16][16] = { 0 }, v[16][16] = { 0 };
364  int u0, v0, u1, v1, udif, vdif;
365  unsigned escape, is8x8, loc;
366 
367  bytestream2_seek(&dgb, s->uv_data_offset + offset, SEEK_SET);
368 
369  is8x8 = bytestream2_get_le16(&dgb);
370  escape = bytestream2_get_le16(&dgb);
371 
372  if (escape == 0 && is8x8 == 0) {
373  u0 = bytestream2_get_byte(&dgb);
374  v0 = bytestream2_get_byte(&dgb);
375  u1 = bytestream2_get_byte(&dgb);
376  v1 = bytestream2_get_byte(&dgb);
377  loc = bytestream2_get_le32(&dgb);
378  u0 = (u0 << 4) | (u0 & 0xF);
379  v0 = (v0 << 4) | (v0 & 0xF);
380  u1 = (u1 << 4) | (u1 & 0xF);
381  v1 = (v1 << 4) | (v1 & 0xF);
382  udif = u1 - u0;
383  vdif = v1 - v0;
384 
385  for (int i = 0; i < 16; i += 4) {
386  for (int j = 0; j < 16; j += 4) {
387  for (int ii = 0; ii < 4; ii++) {
388  for (int jj = 0; jj < 4; jj++) {
389  u[i + ii][j + jj] = u0 + ((udif * (int)(loc & 3) + 2) / 3);
390  v[i + ii][j + jj] = v0 + ((vdif * (int)(loc & 3) + 2) / 3);
391  }
392  }
393 
394  loc >>= 2;
395  }
396  }
397  } else {
398  for (int i = 0; i < 16; i += 8) {
399  for (int j = 0; j < 16; j += 8) {
400  if (is8x8 & 1) {
401  u0 = bytestream2_get_byte(&dgb);
402  v0 = bytestream2_get_byte(&dgb);
403  u1 = bytestream2_get_byte(&dgb);
404  v1 = bytestream2_get_byte(&dgb);
405  loc = bytestream2_get_le32(&dgb);
406  u0 = (u0 << 4) | (u0 & 0xF);
407  v0 = (v0 << 4) | (v0 & 0xF);
408  u1 = (u1 << 4) | (u1 & 0xF);
409  v1 = (v1 << 4) | (v1 & 0xF);
410  udif = u1 - u0;
411  vdif = v1 - v0;
412 
413  for (int ii = 0; ii < 8; ii += 2) {
414  for (int jj = 0; jj < 8; jj += 2) {
415  for (int iii = 0; iii < 2; iii++) {
416  for (int jjj = 0; jjj < 2; jjj++) {
417  u[i + ii + iii][j + jj + jjj] = u0 + ((udif * (int)(loc & 3) + 2) / 3);
418  v[i + ii + iii][j + jj + jjj] = v0 + ((vdif * (int)(loc & 3) + 2) / 3);
419  }
420  }
421 
422  loc >>= 2;
423  }
424  }
425  } else if (escape) {
426  for (int ii = 0; ii < 8; ii += 4) {
427  for (int jj = 0; jj < 8; jj += 4) {
428  u0 = bytestream2_get_byte(&dgb);
429  v0 = bytestream2_get_byte(&dgb);
430  u1 = bytestream2_get_byte(&dgb);
431  v1 = bytestream2_get_byte(&dgb);
432  loc = bytestream2_get_le32(&dgb);
433  u0 = (u0 << 4) | (u0 & 0xF);
434  v0 = (v0 << 4) | (v0 & 0xF);
435  u1 = (u1 << 4) | (u1 & 0xF);
436  v1 = (v1 << 4) | (v1 & 0xF);
437  udif = u1 - u0;
438  vdif = v1 - v0;
439 
440  for (int iii = 0; iii < 4; iii++) {
441  for (int jjj = 0; jjj < 4; jjj++) {
442  u[i + ii + iii][j + jj + jjj] = u0 + ((udif * (int)(loc & 3) + 2) / 3);
443  v[i + ii + iii][j + jj + jjj] = v0 + ((vdif * (int)(loc & 3) + 2) / 3);
444 
445  loc >>= 2;
446  }
447  }
448  }
449  }
450  }
451 
452  is8x8 >>= 1;
453  }
454  }
455  }
456 
457  for (int i = 0; i < 16; i++) {
458  for (int j = 0; j < 16; j++) {
459  dstu[x + i * ulinesize + j] = u[i][j];
460  dstv[x + i * vlinesize + j] = v[i][j];
461  }
462  }
463  }
464 
465  dstu += 16 * ulinesize;
466  dstv += 16 * vlinesize;
467  }
468 
469  return 0;
470 }
471 
472 static int decode_frame(AVCodecContext *avctx,
473  void *data, int *got_frame,
474  AVPacket *avpkt)
475 {
476  NotchLCContext *s = avctx->priv_data;
477  ThreadFrame frame = { .f = data };
478  GetByteContext *gb = &s->gb;
479  PutByteContext *pb = &s->pb;
480  unsigned uncompressed_size;
481  AVFrame *p = data;
482  int ret;
483 
484  if (avpkt->size <= 40)
485  return AVERROR_INVALIDDATA;
486 
487  bytestream2_init(gb, avpkt->data, avpkt->size);
488 
489  if (bytestream2_get_le32(gb) != MKBETAG('N','L','C','1'))
490  return AVERROR_INVALIDDATA;
491 
492  uncompressed_size = bytestream2_get_le32(gb);
493  s->compressed_size = bytestream2_get_le32(gb);
494  s->format = bytestream2_get_le32(gb);
495 
496  if (s->format > 2)
497  return AVERROR_PATCHWELCOME;
498 
499  if (s->format == 0) {
500  ret = ff_lzf_uncompress(gb, &s->lzf_buffer, &s->lzf_size, &s->lzf_alloc_size);
501  if (ret < 0)
502  return ret;
503 
504  if (uncompressed_size > s->lzf_size)
505  return AVERROR_INVALIDDATA;
506 
507  bytestream2_init(gb, s->lzf_buffer, uncompressed_size);
508  } else if (s->format == 1) {
509  if (bytestream2_get_bytes_left(gb) < uncompressed_size / 255)
510  return AVERROR_INVALIDDATA;
511 
512  av_fast_padded_malloc(&s->uncompressed_buffer, &s->uncompressed_size,
513  uncompressed_size);
514  if (!s->uncompressed_buffer)
515  return AVERROR(ENOMEM);
516 
517  bytestream2_init_writer(pb, s->uncompressed_buffer, s->uncompressed_size);
518 
519  ret = lz4_decompress(avctx, gb, pb);
520  if (ret != uncompressed_size)
521  return AVERROR_INVALIDDATA;
522 
523  bytestream2_init(gb, s->uncompressed_buffer, uncompressed_size);
524  }
525 
526  ret = decode_blocks(avctx, p, &frame, uncompressed_size);
527  if (ret < 0)
528  return ret;
529 
531  p->key_frame = 1;
532 
533  *got_frame = 1;
534 
535  return avpkt->size;
536 }
537 
539 {
540  NotchLCContext *s = avctx->priv_data;
541 
542  av_freep(&s->uncompressed_buffer);
543  s->uncompressed_size = 0;
544  av_freep(&s->lzf_buffer);
545  s->lzf_size = 0;
546 
547  return 0;
548 }
549 
551  .name = "notchlc",
552  .long_name = NULL_IF_CONFIG_SMALL("NotchLC"),
553  .type = AVMEDIA_TYPE_VIDEO,
554  .id = AV_CODEC_ID_NOTCHLC,
555  .priv_data_size = sizeof(NotchLCContext),
556  .init = decode_init,
557  .close = decode_end,
558  .decode = decode_frame,
560 };
#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 unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
Definition: bytestream.h:267
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 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
static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p, const uint8_t *src, unsigned int size)
Definition: bytestream.h:286
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:274
#define bit(string, value)
Definition: cbs_mpeg2.c:58
#define s(width, name)
Definition: cbs_vp9.c:257
#define MKBETAG(a, b, c, d)
Definition: common.h:479
#define av_clip_uintp2
Definition: common.h:146
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
static AVFrame * frame
static float add(float src0, float src1)
int
bitstream reader API header.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:677
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:108
@ AV_CODEC_ID_NOTCHLC
Definition: codec_id.h:301
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
Definition: utils.c:50
#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
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
int i
Definition: input.c:407
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:84
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
int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, size_t *size, unsigned *allocated_size)
Decompress LZF data into *buf, reallocating it as needed.
Definition: lzf.c:55
const char data[16]
Definition: mxf.c:142
#define HISTORY_SIZE
Definition: notchlc.c:75
AVCodec ff_notchlc_decoder
Definition: notchlc.c:550
static int decode_blocks(AVCodecContext *avctx, AVFrame *p, ThreadFrame *frame, unsigned uncompressed_size)
Definition: notchlc.c:157
static av_cold int decode_init(AVCodecContext *avctx)
Definition: notchlc.c:64
static av_cold int decode_end(AVCodecContext *avctx)
Definition: notchlc.c:538
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: notchlc.c:472
static int lz4_decompress(AVCodecContext *avctx, GetByteContext *gb, PutByteContext *pb)
Definition: notchlc.c:77
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:586
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
Definition: pixfmt.h:460
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
Definition: pixfmt.h:497
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:440
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
Definition: pixfmt.h:513
FF_ENABLE_DEPRECATION_WARNINGS int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
#define v0
Definition: regdef.h:26
static const SheerTable rgb[2]
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
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:1171
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:1150
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:1164
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:1157
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
const uint8_t * buffer
Definition: bytestream.h:34
uint8_t * uncompressed_buffer
Definition: notchlc.c:39
unsigned y_data_offset
Definition: notchlc.c:52
unsigned uncompressed_size
Definition: notchlc.c:40
unsigned a_count_size
Definition: notchlc.c:57
unsigned format
Definition: notchlc.c:37
unsigned texture_size_x
Definition: notchlc.c:46
unsigned y_control_data_offset
Definition: notchlc.c:50
unsigned lzf_alloc_size
Definition: notchlc.c:44
unsigned uv_count_offset
Definition: notchlc.c:56
uint8_t * lzf_buffer
Definition: notchlc.c:42
PutByteContext pb
Definition: notchlc.c:61
unsigned uv_data_offset
Definition: notchlc.c:53
GetByteContext gb
Definition: notchlc.c:60
unsigned uv_offset_data_offset
Definition: notchlc.c:49
unsigned texture_size_y
Definition: notchlc.c:47
unsigned a_data_offset
Definition: notchlc.c:55
unsigned y_data_row_offsets
Definition: notchlc.c:48
unsigned a_control_word_offset
Definition: notchlc.c:51
unsigned data_end
Definition: notchlc.c:58
size_t lzf_size
Definition: notchlc.c:43
unsigned y_data_size
Definition: notchlc.c:54
unsigned compressed_size
Definition: notchlc.c:36
Definition: rpzaenc.c:58
#define av_freep(p)
static const uint8_t offset[127][2]
Definition: vf_spp.c:107
float delta