FFmpeg
magicyuvenc.c
Go to the documentation of this file.
1 /*
2  * MagicYUV encoder
3  * Copyright (c) 2017 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 <stdlib.h>
23 #include <string.h>
24 
25 #include "libavutil/cpu.h"
26 #include "libavutil/opt.h"
27 #include "libavutil/pixdesc.h"
28 #include "libavutil/qsort.h"
29 
30 #include "avcodec.h"
31 #include "bytestream.h"
32 #include "codec_internal.h"
33 #include "encode.h"
34 #include "put_bits.h"
35 #include "thread.h"
36 #include "lossless_videoencdsp.h"
37 
38 #define MAGICYUV_EXTRADATA_SIZE 32
39 
40 typedef enum Prediction {
41  LEFT = 1,
44 } Prediction;
45 
46 typedef struct HuffEntry {
47  uint8_t len;
48  uint32_t code;
49 } HuffEntry;
50 
51 typedef struct PTable {
52  int value; ///< input value
53  int64_t prob; ///< number of occurences of this value in input
54 } PTable;
55 
56 typedef struct Slice {
57  unsigned pos;
58  unsigned size;
59  uint8_t *slice;
60  uint8_t *bitslice;
61  PTable counts[256];
62 } Slice;
63 
64 typedef struct MagicYUVContext {
65  const AVClass *class;
67  int planes;
68  uint8_t format;
69  int slice_height;
70  int nb_slices;
71  int correlate;
72  int hshift[4];
73  int vshift[4];
74  unsigned bitslice_size;
75  uint8_t *decorrelate_buf[2];
76  Slice *slices;
77  HuffEntry he[4][256];
79  void (*predict)(struct MagicYUVContext *s, const uint8_t *src, uint8_t *dst,
80  ptrdiff_t stride, int width, int height);
82 
84  const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
85  int width, int height)
86 {
87  uint8_t prev = 0;
88  int i, j;
89 
90  for (i = 0; i < width; i++) {
91  dst[i] = src[i] - prev;
92  prev = src[i];
93  }
94  dst += width;
95  src += stride;
96  for (j = 1; j < height; j++) {
97  prev = src[-stride];
98  for (i = 0; i < width; i++) {
99  dst[i] = src[i] - prev;
100  prev = src[i];
101  }
102  dst += width;
103  src += stride;
104  }
105 }
106 
108  const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
109  int width, int height)
110 {
111  int left = 0, top, lefttop;
112  int i, j;
113 
114  for (i = 0; i < width; i++) {
115  dst[i] = src[i] - left;
116  left = src[i];
117  }
118  dst += width;
119  src += stride;
120  for (j = 1; j < height; j++) {
121  top = src[-stride];
122  left = src[0] - top;
123  dst[0] = left;
124  for (i = 1; i < width; i++) {
125  top = src[i - stride];
126  lefttop = src[i - (stride + 1)];
127  left = src[i-1];
128  dst[i] = (src[i] - top) - left + lefttop;
129  }
130  dst += width;
131  src += stride;
132  }
133 }
134 
136  const uint8_t *src, uint8_t *dst, ptrdiff_t stride,
137  int width, int height)
138 {
139  int left = 0, lefttop;
140  int i, j;
141 
142  for (i = 0; i < width; i++) {
143  dst[i] = src[i] - left;
144  left = src[i];
145  }
146  dst += width;
147  src += stride;
148  for (j = 1; j < height; j++) {
149  left = lefttop = src[-stride];
150  s->llvidencdsp.sub_median_pred(dst, src - stride, src, width, &left, &lefttop);
151  dst += width;
152  src += stride;
153  }
154 }
155 
157 {
158  MagicYUVContext *s = avctx->priv_data;
159  PutByteContext pb;
160 
161  switch (avctx->pix_fmt) {
162  case AV_PIX_FMT_GBRP:
163  avctx->codec_tag = MKTAG('M', '8', 'R', 'G');
164  s->correlate = 1;
165  s->format = 0x65;
166  break;
167  case AV_PIX_FMT_GBRAP:
168  avctx->codec_tag = MKTAG('M', '8', 'R', 'A');
169  s->correlate = 1;
170  s->format = 0x66;
171  break;
172  case AV_PIX_FMT_YUV420P:
173  avctx->codec_tag = MKTAG('M', '8', 'Y', '0');
174  s->hshift[1] =
175  s->vshift[1] =
176  s->hshift[2] =
177  s->vshift[2] = 1;
178  s->format = 0x69;
179  break;
180  case AV_PIX_FMT_YUV422P:
181  avctx->codec_tag = MKTAG('M', '8', 'Y', '2');
182  s->hshift[1] =
183  s->hshift[2] = 1;
184  s->format = 0x68;
185  break;
186  case AV_PIX_FMT_YUV444P:
187  avctx->codec_tag = MKTAG('M', '8', 'Y', '4');
188  s->format = 0x67;
189  break;
190  case AV_PIX_FMT_YUVA444P:
191  avctx->codec_tag = MKTAG('M', '8', 'Y', 'A');
192  s->format = 0x6a;
193  break;
194  case AV_PIX_FMT_GRAY8:
195  avctx->codec_tag = MKTAG('M', '8', 'G', '0');
196  s->format = 0x6b;
197  break;
198  }
199 
200  ff_llvidencdsp_init(&s->llvidencdsp);
201 
202  s->planes = av_pix_fmt_count_planes(avctx->pix_fmt);
203 
204  s->nb_slices = (avctx->slices <= 0) ? av_cpu_count() : avctx->slices;
205  s->nb_slices = FFMIN(s->nb_slices, avctx->height >> s->vshift[1]);
206  s->nb_slices = FFMAX(1, s->nb_slices);
207  s->slice_height = FFALIGN((avctx->height + s->nb_slices - 1) / s->nb_slices, 1 << s->vshift[1]);
208  s->nb_slices = (avctx->height + s->slice_height - 1) / s->slice_height;
209  s->slices = av_calloc(s->nb_slices * s->planes, sizeof(*s->slices));
210  if (!s->slices)
211  return AVERROR(ENOMEM);
212 
213  if (s->correlate) {
214  s->decorrelate_buf[0] = av_calloc(2U * (s->nb_slices * s->slice_height), FFALIGN(avctx->width, av_cpu_max_align()));
215  if (!s->decorrelate_buf[0])
216  return AVERROR(ENOMEM);
217  s->decorrelate_buf[1] = s->decorrelate_buf[0] + (s->nb_slices * s->slice_height) * FFALIGN(avctx->width, av_cpu_max_align());
218  }
219 
220  s->bitslice_size = avctx->width * s->slice_height + 2;
221  for (int n = 0; n < s->nb_slices; n++) {
222  for (int i = 0; i < s->planes; i++) {
223  Slice *sl = &s->slices[n * s->planes + i];
224 
225  sl->bitslice = av_malloc(s->bitslice_size + AV_INPUT_BUFFER_PADDING_SIZE);
226  sl->slice = av_malloc(avctx->width * (s->slice_height + 2) +
228  if (!sl->slice || !sl->bitslice) {
229  av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer.\n");
230  return AVERROR(ENOMEM);
231  }
232  }
233  }
234 
235  switch (s->frame_pred) {
236  case LEFT: s->predict = left_predict; break;
237  case GRADIENT: s->predict = gradient_predict; break;
238  case MEDIAN: s->predict = median_predict; break;
239  }
240 
242 
243  avctx->extradata = av_mallocz(avctx->extradata_size +
245 
246  if (!avctx->extradata) {
247  av_log(avctx, AV_LOG_ERROR, "Could not allocate extradata.\n");
248  return AVERROR(ENOMEM);
249  }
250 
252  bytestream2_put_le32(&pb, MKTAG('M', 'A', 'G', 'Y'));
253  bytestream2_put_le32(&pb, 32);
254  bytestream2_put_byte(&pb, 7);
255  bytestream2_put_byte(&pb, s->format);
256  bytestream2_put_byte(&pb, 12);
257  bytestream2_put_byte(&pb, 0);
258 
259  bytestream2_put_byte(&pb, 0);
260  bytestream2_put_byte(&pb, 0);
261  bytestream2_put_byte(&pb, 32);
262  bytestream2_put_byte(&pb, 0);
263 
264  bytestream2_put_le32(&pb, avctx->width);
265  bytestream2_put_le32(&pb, avctx->height);
266  bytestream2_put_le32(&pb, avctx->width);
267  bytestream2_put_le32(&pb, avctx->height);
268 
269  return 0;
270 }
271 
272 static void calculate_codes(HuffEntry *he, uint16_t codes_count[33])
273 {
274  for (unsigned i = 32, nb_codes = 0; i > 0; i--) {
275  uint16_t curr = codes_count[i]; // # of leafs of length i
276  codes_count[i] = nb_codes / 2; // # of non-leaf nodes on level i
277  nb_codes = codes_count[i] + curr; // # of nodes on level i
278  }
279 
280  for (unsigned i = 0; i < 256; i++) {
281  he[i].code = codes_count[he[i].len];
282  codes_count[he[i].len]++;
283  }
284 }
285 
286 static void count_usage(const uint8_t *src, int width,
287  int height, PTable *counts)
288 {
289  for (int j = 0; j < height; j++) {
290  for (int i = 0; i < width; i++)
291  counts[src[i]].prob++;
292  src += width;
293  }
294 }
295 
296 typedef struct PackageMergerList {
297  int nitems; ///< number of items in the list and probability ex. 4
298  int item_idx[515]; ///< index range for each item in items 0, 2, 5, 9, 13
299  int probability[514]; ///< probability of each item 3, 8, 18, 46
300  int items[257 * 16]; ///< chain of all individual values that make up items A, B, A, B, C, A, B, C, D, C, D, D, E
302 
303 static int compare_by_prob(const void *a, const void *b)
304 {
305  const PTable *a2 = a;
306  const PTable *b2 = b;
307  return a2->prob - b2->prob;
308 }
309 
310 static void magy_huffman_compute_bits(PTable *prob_table, HuffEntry *distincts,
311  uint16_t codes_counts[33],
312  int size, int max_length)
313 {
314  PackageMergerList list_a, list_b, *to = &list_a, *from = &list_b, *temp;
315  int times, i, j, k;
316  int nbits[257] = {0};
317  int min;
318 
319  av_assert0(max_length > 0);
320 
321  to->nitems = 0;
322  from->nitems = 0;
323  to->item_idx[0] = 0;
324  from->item_idx[0] = 0;
325  AV_QSORT(prob_table, size, PTable, compare_by_prob);
326 
327  for (times = 0; times <= max_length; times++) {
328  to->nitems = 0;
329  to->item_idx[0] = 0;
330 
331  j = 0;
332  k = 0;
333 
334  if (times < max_length) {
335  i = 0;
336  }
337  while (i < size || j + 1 < from->nitems) {
338  to->nitems++;
339  to->item_idx[to->nitems] = to->item_idx[to->nitems - 1];
340  if (i < size &&
341  (j + 1 >= from->nitems ||
342  prob_table[i].prob <
343  from->probability[j] + from->probability[j + 1])) {
344  to->items[to->item_idx[to->nitems]++] = prob_table[i].value;
345  to->probability[to->nitems - 1] = prob_table[i].prob;
346  i++;
347  } else {
348  for (k = from->item_idx[j]; k < from->item_idx[j + 2]; k++) {
349  to->items[to->item_idx[to->nitems]++] = from->items[k];
350  }
351  to->probability[to->nitems - 1] =
352  from->probability[j] + from->probability[j + 1];
353  j += 2;
354  }
355  }
356  temp = to;
357  to = from;
358  from = temp;
359  }
360 
361  min = (size - 1 < from->nitems) ? size - 1 : from->nitems;
362  for (i = 0; i < from->item_idx[min]; i++) {
363  nbits[from->items[i]]++;
364  }
365 
366  for (i = 0; i < size; i++) {
367  distincts[i].len = nbits[i];
368  codes_counts[nbits[i]]++;
369  }
370 }
371 
372 static int count_plane_slice(AVCodecContext *avctx, int n, int plane)
373 {
374  MagicYUVContext *s = avctx->priv_data;
375  Slice *sl = &s->slices[n * s->planes + plane];
376  const uint8_t *dst = sl->slice;
377  PTable *counts = sl->counts;
378 
379  memset(counts, 0, sizeof(sl->counts));
380 
381  count_usage(dst, AV_CEIL_RSHIFT(avctx->width, s->hshift[plane]),
382  AV_CEIL_RSHIFT(s->slice_height, s->vshift[plane]), counts);
383 
384  return 0;
385 }
386 
387 static int encode_table(AVCodecContext *avctx,
388  PutBitContext *pb, HuffEntry *he, int plane)
389 {
390  MagicYUVContext *s = avctx->priv_data;
391  PTable counts[256] = { {0} };
392  uint16_t codes_counts[33] = { 0 };
393 
394  for (int n = 0; n < s->nb_slices; n++) {
395  Slice *sl = &s->slices[n * s->planes + plane];
396  PTable *slice_counts = sl->counts;
397 
398  for (int i = 0; i < 256; i++)
399  counts[i].prob = slice_counts[i].prob;
400  }
401 
402  for (int i = 0; i < 256; i++) {
403  counts[i].prob++;
404  counts[i].value = i;
405  }
406 
407  magy_huffman_compute_bits(counts, he, codes_counts, 256, 12);
408 
409  calculate_codes(he, codes_counts);
410 
411  for (int i = 0; i < 256; i++) {
412  put_bits(pb, 1, 0);
413  put_bits(pb, 7, he[i].len);
414  }
415 
416  return 0;
417 }
418 
419 static int encode_plane_slice_raw(const uint8_t *src, uint8_t *dst, unsigned dst_size,
420  int width, int height, int prediction)
421 {
422  unsigned count = width * height;
423 
424  dst[0] = 1;
425  dst[1] = prediction;
426 
427  memcpy(dst + 2, src, count);
428  count += 2;
429  AV_WN32(dst + count, 0);
430  if (count & 3)
431  count += 4 - (count & 3);
432 
433  return count;
434 }
435 
436 static int encode_plane_slice(const uint8_t *src, uint8_t *dst, unsigned dst_size,
437  int width, int height, HuffEntry *he, int prediction)
438 {
439  const uint8_t *osrc = src;
440  PutBitContext pb;
441  int count;
442 
443  init_put_bits(&pb, dst, dst_size);
444 
445  put_bits(&pb, 8, 0);
446  put_bits(&pb, 8, prediction);
447 
448  for (int j = 0; j < height; j++) {
449  for (int i = 0; i < width; i++) {
450  const int idx = src[i];
451  const int len = he[idx].len;
452  if (put_bits_left(&pb) < len + 32)
453  return encode_plane_slice_raw(osrc, dst, dst_size, width, height, prediction);
454  put_bits(&pb, len, he[idx].code);
455  }
456 
457  src += width;
458  }
459 
460  count = put_bits_count(&pb) & 0x1F;
461 
462  if (count)
463  put_bits(&pb, 32 - count, 0);
464 
465  flush_put_bits(&pb);
466 
467  return put_bytes_output(&pb);
468 }
469 
470 static int encode_slice(AVCodecContext *avctx, void *tdata,
471  int n, int threadnr)
472 {
473  MagicYUVContext *s = avctx->priv_data;
474  const int slice_height = s->slice_height;
475  const int last_height = FFMIN(slice_height, avctx->height - n * slice_height);
476  const int height = (n < (s->nb_slices - 1)) ? slice_height : last_height;
477 
478  for (int i = 0; i < s->planes; i++) {
479  Slice *sl = &s->slices[n * s->planes + i];
480 
481  sl->size =
483  sl->bitslice,
484  s->bitslice_size,
485  AV_CEIL_RSHIFT(avctx->width, s->hshift[i]),
486  AV_CEIL_RSHIFT(height, s->vshift[i]),
487  s->he[i], s->frame_pred);
488  }
489 
490  return 0;
491 }
492 
493 static int predict_slice(AVCodecContext *avctx, void *tdata,
494  int n, int threadnr)
495 {
496  const int aligned_width = FFALIGN(avctx->width, av_cpu_max_align());
497  MagicYUVContext *s = avctx->priv_data;
498  const int slice_height = s->slice_height;
499  const int last_height = FFMIN(slice_height, avctx->height - n * slice_height);
500  const int height = (n < (s->nb_slices - 1)) ? slice_height : last_height;
501  const int width = avctx->width;
502  AVFrame *frame = tdata;
503 
504  if (s->correlate) {
505  uint8_t *decorrelated[2] = { s->decorrelate_buf[0] + n * slice_height * aligned_width,
506  s->decorrelate_buf[1] + n * slice_height * aligned_width };
507  const int decorrelate_linesize = aligned_width;
508  const uint8_t *const data[4] = { decorrelated[0], frame->data[0] + n * slice_height * frame->linesize[0],
509  decorrelated[1], s->planes == 4 ? frame->data[3] + n * slice_height * frame->linesize[3] : NULL };
510  const uint8_t *r, *g, *b;
511  const int linesize[4] = { decorrelate_linesize, frame->linesize[0],
512  decorrelate_linesize, frame->linesize[3] };
513 
514  g = frame->data[0] + n * slice_height * frame->linesize[0];
515  b = frame->data[1] + n * slice_height * frame->linesize[1];
516  r = frame->data[2] + n * slice_height * frame->linesize[2];
517 
518  for (int i = 0; i < height; i++) {
519  s->llvidencdsp.diff_bytes(decorrelated[0], b, g, width);
520  s->llvidencdsp.diff_bytes(decorrelated[1], r, g, width);
521  g += frame->linesize[0];
522  b += frame->linesize[1];
523  r += frame->linesize[2];
524  decorrelated[0] += decorrelate_linesize;
525  decorrelated[1] += decorrelate_linesize;
526  }
527 
528  for (int i = 0; i < s->planes; i++) {
529  Slice *sl = &s->slices[n * s->planes + i];
530 
531  s->predict(s, data[i], sl->slice, linesize[i],
532  frame->width, height);
533  }
534  } else {
535  for (int i = 0; i < s->planes; i++) {
536  Slice *sl = &s->slices[n * s->planes + i];
537 
538  s->predict(s, frame->data[i] + n * (slice_height >> s->vshift[i]) * frame->linesize[i],
539  sl->slice,
540  frame->linesize[i],
541  AV_CEIL_RSHIFT(frame->width, s->hshift[i]),
542  AV_CEIL_RSHIFT(height, s->vshift[i]));
543  }
544  }
545 
546  for (int p = 0; p < s->planes; p++)
547  count_plane_slice(avctx, n, p);
548 
549  return 0;
550 }
551 
553  const AVFrame *frame, int *got_packet)
554 {
555  MagicYUVContext *s = avctx->priv_data;
556  const int width = avctx->width, height = avctx->height;
557  const int slice_height = s->slice_height;
558  unsigned tables_size;
559  PutBitContext pbit;
560  PutByteContext pb;
561  int pos, ret = 0;
562 
563  ret = ff_alloc_packet(avctx, pkt, (256 + 4 * s->nb_slices + width * height) *
564  s->planes + 256);
565  if (ret < 0)
566  return ret;
567 
569  bytestream2_put_le32(&pb, MKTAG('M', 'A', 'G', 'Y'));
570  bytestream2_put_le32(&pb, 32); // header size
571  bytestream2_put_byte(&pb, 7); // version
572  bytestream2_put_byte(&pb, s->format);
573  bytestream2_put_byte(&pb, 12); // max huffman length
574  bytestream2_put_byte(&pb, 0);
575 
576  bytestream2_put_byte(&pb, 0);
577  bytestream2_put_byte(&pb, 0);
578  bytestream2_put_byte(&pb, 32); // coder type
579  bytestream2_put_byte(&pb, 0);
580 
581  bytestream2_put_le32(&pb, avctx->width);
582  bytestream2_put_le32(&pb, avctx->height);
583  bytestream2_put_le32(&pb, avctx->width);
584  bytestream2_put_le32(&pb, slice_height);
585  bytestream2_put_le32(&pb, 0);
586 
587  for (int i = 0; i < s->planes; i++) {
588  bytestream2_put_le32(&pb, 0);
589  for (int j = 1; j < s->nb_slices; j++)
590  bytestream2_put_le32(&pb, 0);
591  }
592 
593  bytestream2_put_byte(&pb, s->planes);
594 
595  for (int i = 0; i < s->planes; i++) {
596  for (int n = 0; n < s->nb_slices; n++)
597  bytestream2_put_byte(&pb, n * s->planes + i);
598  }
599 
600  avctx->execute2(avctx, predict_slice, (void *)frame, NULL, s->nb_slices);
601 
603 
604  for (int i = 0; i < s->planes; i++)
605  encode_table(avctx, &pbit, s->he[i], i);
606 
607  tables_size = put_bytes_count(&pbit, 1);
608  bytestream2_skip_p(&pb, tables_size);
609 
610  avctx->execute2(avctx, encode_slice, NULL, NULL, s->nb_slices);
611 
612  for (int n = 0; n < s->nb_slices; n++) {
613  for (int i = 0; i < s->planes; i++) {
614  Slice *sl = &s->slices[n * s->planes + i];
615 
616  sl->pos = bytestream2_tell_p(&pb);
617 
618  bytestream2_put_buffer(&pb, sl->bitslice, sl->size);
619  }
620  }
621 
622  pos = bytestream2_tell_p(&pb);
623  bytestream2_seek_p(&pb, 32, SEEK_SET);
624  bytestream2_put_le32(&pb, s->slices[0].pos - 32);
625  for (int i = 0; i < s->planes; i++) {
626  for (int n = 0; n < s->nb_slices; n++) {
627  Slice *sl = &s->slices[n * s->planes + i];
628 
629  bytestream2_put_le32(&pb, sl->pos - 32);
630  }
631  }
632  bytestream2_seek_p(&pb, pos, SEEK_SET);
633 
634  pkt->size = bytestream2_tell_p(&pb);
635 
636  *got_packet = 1;
637 
638  return 0;
639 }
640 
642 {
643  MagicYUVContext *s = avctx->priv_data;
644 
645  for (int i = 0; i < s->planes * s->nb_slices && s->slices; i++) {
646  Slice *sl = &s->slices[i];
647 
648  av_freep(&sl->slice);
649  av_freep(&sl->bitslice);
650  }
651  av_freep(&s->slices);
652  av_freep(&s->decorrelate_buf);
653 
654  return 0;
655 }
656 
657 #define OFFSET(x) offsetof(MagicYUVContext, x)
658 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
659 static const AVOption options[] = {
660  { "pred", "Prediction method", OFFSET(frame_pred), AV_OPT_TYPE_INT, {.i64=LEFT}, LEFT, MEDIAN, VE, .unit = "pred" },
661  { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LEFT }, 0, 0, VE, .unit = "pred" },
662  { "gradient", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = GRADIENT }, 0, 0, VE, .unit = "pred" },
663  { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MEDIAN }, 0, 0, VE, .unit = "pred" },
664  { NULL},
665 };
666 
667 static const AVClass magicyuv_class = {
668  .class_name = "magicyuv",
669  .item_name = av_default_item_name,
670  .option = options,
671  .version = LIBAVUTIL_VERSION_INT,
672 };
673 
675  .p.name = "magicyuv",
676  CODEC_LONG_NAME("MagicYUV video"),
677  .p.type = AVMEDIA_TYPE_VIDEO,
678  .p.id = AV_CODEC_ID_MAGICYUV,
679  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
682  .priv_data_size = sizeof(MagicYUVContext),
683  .p.priv_class = &magicyuv_class,
684  .init = magy_encode_init,
685  .close = magy_encode_close,
687  .p.pix_fmts = (const enum AVPixelFormat[]) {
691  },
692  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
693 };
GRADIENT
@ GRADIENT
Definition: magicyuvenc.c:42
VE
#define VE
Definition: magicyuvenc.c:658
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
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
r
const char * r
Definition: vf_curves.c:126
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
opt.h
Prediction
Definition: aptx.h:70
count_usage
static void count_usage(const uint8_t *src, int width, int height, PTable *counts)
Definition: magicyuvenc.c:286
put_bytes_output
static int put_bytes_output(const PutBitContext *s)
Definition: put_bits.h:89
HuffEntry::len
uint8_t len
Definition: exr.c:95
MagicYUVContext::nb_slices
int nb_slices
Definition: magicyuv.c:60
ff_magicyuv_encoder
const FFCodec ff_magicyuv_encoder
Definition: magicyuvenc.c:674
compare_by_prob
static int compare_by_prob(const void *a, const void *b)
Definition: magicyuvenc.c:303
MagicYUVContext::hshift
int hshift[4]
Definition: magicyuv.c:67
left_predict
static void left_predict(MagicYUVContext *s, const uint8_t *src, uint8_t *dst, ptrdiff_t stride, int width, int height)
Definition: magicyuvenc.c:83
int64_t
long long int64_t
Definition: coverity.c:34
init_put_bits
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:62
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:222
pixdesc.h
Slice::slice
uint8_t * slice
Definition: magicyuvenc.c:59
AVFrame::width
int width
Definition: frame.h:416
AVPacket::data
uint8_t * data
Definition: packet.h:522
AVOption
AVOption.
Definition: opt.h:346
encode.h
b
#define b
Definition: input.c:41
put_bytes_count
static int put_bytes_count(const PutBitContext *s, int round_up)
Definition: put_bits.h:100
PackageMergerList::item_idx
int item_idx[515]
index range for each item in items 0, 2, 5, 9, 13
Definition: magicyuvenc.c:298
bytestream2_tell_p
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
Definition: bytestream.h:197
data
const char data[16]
Definition: mxf.c:148
FFCodec
Definition: codec_internal.h:127
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
Slice::size
uint32_t size
Definition: magicyuv.c:41
thread.h
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
MagicYUVContext
Definition: magicyuv.c:55
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3002
MagicYUVContext::llvidencdsp
LLVidEncDSPContext llvidencdsp
Definition: magicyuvenc.c:78
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
magy_encode_frame
static int magy_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
Definition: magicyuvenc.c:552
calculate_codes
static void calculate_codes(HuffEntry *he, uint16_t codes_count[33])
Definition: magicyuvenc.c:272
count_plane_slice
static int count_plane_slice(AVCodecContext *avctx, int n, int plane)
Definition: magicyuvenc.c:372
put_bits_left
static int put_bits_left(PutBitContext *s)
Definition: put_bits.h:125
MagicYUVContext::predict
void(* predict)(struct MagicYUVContext *s, const uint8_t *src, uint8_t *dst, ptrdiff_t stride, int width, int height)
Definition: magicyuvenc.c:79
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:296
encode_table
static int encode_table(AVCodecContext *avctx, PutBitContext *pb, HuffEntry *he, int plane)
Definition: magicyuvenc.c:387
magicyuv_class
static const AVClass magicyuv_class
Definition: magicyuvenc.c:667
OFFSET
#define OFFSET(x)
Definition: magicyuvenc.c:657
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
bytestream2_get_bytes_left_p
static av_always_inline int bytestream2_get_bytes_left_p(PutByteContext *p)
Definition: bytestream.h:163
av_cold
#define av_cold
Definition: attributes.h:90
bytestream2_init_writer
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
Definition: bytestream.h:147
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:524
MEDIAN
@ MEDIAN
Definition: magicyuvenc.c:43
Prediction
Prediction
Definition: magicyuvenc.c:40
width
#define width
Slice::size
unsigned size
Definition: magicyuvenc.c:58
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
g
const char * g
Definition: vf_curves.c:127
PackageMergerList::nitems
int nitems
number of items in the list and probability ex. 4
Definition: magicyuvenc.c:297
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
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
from
const char * from
Definition: jacosubdec.c:66
to
const char * to
Definition: webvttdec.c:35
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
Slice
Definition: magicyuv.c:39
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
PTable::prob
int64_t prob
number of occurences of this value in input
Definition: magicyuvenc.c:53
median_predict
static void median_predict(MagicYUVContext *s, const uint8_t *src, uint8_t *dst, ptrdiff_t stride, int width, int height)
Definition: magicyuvenc.c:135
PutBitContext
Definition: put_bits.h:50
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
frame
static AVFrame * frame
Definition: demux_decode.c:54
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
MagicYUVContext::vshift
int vshift[4]
Definition: magicyuv.c:68
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
PTable
Used to assign a occurrence count or "probability" to an input value.
Definition: magicyuvenc.c:51
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
av_cpu_max_align
size_t av_cpu_max_align(void)
Get the maximum data alignment that may be required by FFmpeg.
Definition: cpu.c:268
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
MagicYUVContext::slices
Slice * slices[4]
Definition: magicyuv.c:69
MagicYUVContext::correlate
int correlate
Definition: magicyuvenc.c:71
AV_CODEC_ID_MAGICYUV
@ AV_CODEC_ID_MAGICYUV
Definition: codec_id.h:270
Slice::pos
unsigned pos
Definition: magicyuvenc.c:57
ff_llvidencdsp_init
av_cold void ff_llvidencdsp_init(LLVidEncDSPContext *c)
Definition: lossless_videoencdsp.c:100
MagicYUVContext::he
HuffEntry he[1<< 14]
Definition: magicyuv.c:76
PutByteContext
Definition: bytestream.h:37
av_cpu_count
int av_cpu_count(void)
Definition: cpu.c:209
qsort.h
Slice::counts
PTable counts[256]
Definition: magicyuvenc.c:61
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
PackageMergerList
Used to store intermediate lists in the package merge algorithm.
Definition: magicyuvenc.c:296
AVPacket::size
int size
Definition: packet.h:523
codec_internal.h
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:374
cpu.h
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
options
static const AVOption options[]
Definition: magicyuvenc.c:659
MagicYUVContext::bitslice_size
unsigned bitslice_size
Definition: magicyuvenc.c:74
size
int size
Definition: twinvq_data.h:10344
prediction
static int64_t prediction(int delta, ChannelContext *c)
Definition: misc4.c:78
height
#define height
b2
static double b2(void *priv, double x, double y)
Definition: vf_xfade.c:2036
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
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
MagicYUVContext::slice_height
int slice_height
Definition: magicyuv.c:59
AV_CODEC_CAP_SLICE_THREADS
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:114
PTable::value
int value
input value
Definition: magicyuvenc.c:52
magy_encode_close
static av_cold int magy_encode_close(AVCodecContext *avctx)
Definition: magicyuvenc.c:641
lossless_videoencdsp.h
MagicYUVContext::frame_pred
int frame_pred
Definition: magicyuvenc.c:66
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
code
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
Definition: filter_design.txt:178
put_bits_count
static int put_bits_count(PutBitContext *s)
Definition: put_bits.h:80
AV_QSORT
#define AV_QSORT(p, num, type, cmp)
Quicksort This sort is fast, and fully inplace but not stable and it is possible to construct input t...
Definition: qsort.h:33
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:523
encode_plane_slice_raw
static int encode_plane_slice_raw(const uint8_t *src, uint8_t *dst, unsigned dst_size, int width, int height, int prediction)
Definition: magicyuvenc.c:419
bytestream2_skip_p
static av_always_inline void bytestream2_skip_p(PutByteContext *p, unsigned int size)
Definition: bytestream.h:180
a2
#define a2
Definition: regdef.h:48
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:254
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
PackageMergerList::items
int items[257 *16]
chain of all individual values that make up items A, B, A, B, C, A, B, C, D, C, D,...
Definition: magicyuvenc.c:300
len
int len
Definition: vorbis_enc_data.h:426
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
LLVidEncDSPContext
Definition: lossless_videoencdsp.h:25
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
LEFT
@ LEFT
Definition: magicyuvenc.c:41
avcodec.h
stride
#define stride
Definition: h264pred_template.c:537
MAGICYUV_EXTRADATA_SIZE
#define MAGICYUV_EXTRADATA_SIZE
Definition: magicyuvenc.c:38
ret
ret
Definition: filter_design.txt:187
MagicYUVContext::decorrelate_buf
uint8_t * decorrelate_buf[2]
Definition: magicyuvenc.c:75
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
encode_slice
static int encode_slice(AVCodecContext *avctx, void *tdata, int n, int threadnr)
Definition: magicyuvenc.c:470
prob
#define prob(name, subs,...)
Definition: cbs_vp9.c:325
pos
unsigned int pos
Definition: spdifenc.c:413
encode_plane_slice
static int encode_plane_slice(const uint8_t *src, uint8_t *dst, unsigned dst_size, int width, int height, HuffEntry *he, int prediction)
Definition: magicyuvenc.c:436
HuffEntry::code
uint32_t code
Definition: exr.c:97
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
left
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
Definition: snow.txt:386
U
#define U(x)
Definition: vpx_arith.h:37
AVCodecContext
main external API structure.
Definition: avcodec.h:445
predict_slice
static int predict_slice(AVCodecContext *avctx, void *tdata, int n, int threadnr)
Definition: magicyuvenc.c:493
magy_encode_init
static av_cold int magy_encode_init(AVCodecContext *avctx)
Definition: magicyuvenc.c:156
PackageMergerList::probability
int probability[514]
probability of each item 3, 8, 18, 46
Definition: magicyuvenc.c:299
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
bytestream2_seek_p
static av_always_inline int bytestream2_seek_p(PutByteContext *p, int offset, int whence)
Definition: bytestream.h:236
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
HuffEntry
Definition: exr.c:94
temp
else temp
Definition: vf_mcdeint.c:263
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
Slice::bitslice
uint8_t * bitslice
Definition: magicyuvenc.c:60
flush_put_bits
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:143
AVCodecContext::codec_tag
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:470
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AVCodecContext::slices
int slices
Number of slices.
Definition: avcodec.h:1047
AVPacket
This structure stores compressed data.
Definition: packet.h:499
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:472
MagicYUVContext::planes
int planes
Definition: magicyuv.c:61
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
gradient_predict
static void gradient_predict(MagicYUVContext *s, const uint8_t *src, uint8_t *dst, ptrdiff_t stride, int width, int height)
Definition: magicyuvenc.c:107
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:618
bytestream.h
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
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
put_bits.h
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
AVCodecContext::execute2
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
Definition: avcodec.h:1631
ff_alloc_packet
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
Definition: encode.c:61
magy_huffman_compute_bits
static void magy_huffman_compute_bits(PTable *prob_table, HuffEntry *distincts, uint16_t codes_counts[33], int size, int max_length)
Definition: magicyuvenc.c:310
MagicYUVContext::format
uint8_t format
Definition: magicyuvenc.c:68
min
float min
Definition: vorbis_enc_data.h:429