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