FFmpeg
Loading...
Searching...
No Matches
huffyuvenc.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2002-2014 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * see https://multimedia.cx/huffyuv.txt for a description of
5 * the algorithm used
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 * yuva, gray, 4:4:4, 4:1:1, 4:1:0 and >8 bit per sample support sponsored by NOA
24 */
25
26/**
27 * @file
28 * huffyuv encoder
29 */
30
31#include "config_components.h"
32
33#include "avcodec.h"
34#include "bswapdsp.h"
35#include "codec_internal.h"
36#include "encode.h"
37#include "huffyuv.h"
38#include "huffman.h"
39#include "huffyuvencdsp.h"
41#include "put_bits.h"
42#include "libavutil/mem.h"
43#include "libavutil/opt.h"
44#include "libavutil/pixdesc.h"
45
46typedef struct HYuvEncContext {
47 AVClass *class;
50 /* Predictor, use int for AVOption */
56 int bps;
57 unsigned mask; // (1<<bps)-1
58 int vlc_n; // number of vlc codes (FFMIN(1<<bps, MAX_VLC_N))
59 int alpha;
60 int chroma;
61 int yuv;
64 int flags;
67
68 union {
69 uint8_t *temp[3];
70 uint16_t *temp16[3];
71 };
72 uint64_t stats[4][MAX_VLC_N];
73 uint8_t len[4][MAX_VLC_N];
74 uint32_t bits[4][MAX_VLC_N];
78 int non_determ; // non-deterministic, multi-threaded encoder allowed
80
81static inline void diff_bytes(HYuvEncContext *s, uint8_t *dst,
82 const uint8_t *src0, const uint8_t *src1, int w)
83{
84 if (s->bps <= 8) {
85 s->llvidencdsp.diff_bytes(dst, src0, src1, w);
86 } else {
87 s->hencdsp.diff_int16((uint16_t *)dst, (const uint16_t *)src0, (const uint16_t *)src1, s->mask, w);
88 }
89}
90
91static inline int sub_left_prediction(HYuvEncContext *s, uint8_t *dst,
92 const uint8_t *src, int w, int left)
93{
94 int i;
95 int min_width = FFMIN(w, 32);
96
97 if (s->bps <= 8) {
98 for (i = 0; i < min_width; i++) { /* scalar loop before dsp call */
99 const int temp = src[i];
100 dst[i] = temp - left;
101 left = temp;
102 }
103 if (w < 32)
104 return left;
105 s->llvidencdsp.diff_bytes(dst + 32, src + 32, src + 31, w - 32);
106 return src[w-1];
107 } else {
108 const uint16_t *src16 = (const uint16_t *)src;
109 uint16_t *dst16 = ( uint16_t *)dst;
110 for (i = 0; i < min_width; i++) { /* scalar loop before dsp call */
111 const int temp = src16[i];
112 dst16[i] = temp - left;
113 left = temp;
114 }
115 if (w < 32)
116 return left;
117 s->hencdsp.diff_int16(dst16 + 32, src16 + 32, src16 + 31, s->mask, w - 32);
118 return src16[w-1];
119 }
120}
121
122static inline void sub_left_prediction_bgr32(HYuvEncContext *s, uint8_t *dst,
123 const uint8_t *src, int w,
124 int *red, int *green, int *blue,
125 int *alpha)
126{
127 int i;
128 int r, g, b, a;
129 int min_width = FFMIN(w, 8);
130 r = *red;
131 g = *green;
132 b = *blue;
133 a = *alpha;
134
135 for (i = 0; i < min_width; i++) {
136 const int rt = src[i * 4 + R];
137 const int gt = src[i * 4 + G];
138 const int bt = src[i * 4 + B];
139 const int at = src[i * 4 + A];
140 dst[i * 4 + R] = rt - r;
141 dst[i * 4 + G] = gt - g;
142 dst[i * 4 + B] = bt - b;
143 dst[i * 4 + A] = at - a;
144 r = rt;
145 g = gt;
146 b = bt;
147 a = at;
148 }
149
150 s->llvidencdsp.diff_bytes(dst + 32, src + 32, src + 32 - 4, w * 4 - 32);
151
152 *red = src[(w - 1) * 4 + R];
153 *green = src[(w - 1) * 4 + G];
154 *blue = src[(w - 1) * 4 + B];
155 *alpha = src[(w - 1) * 4 + A];
156}
157
158static inline void sub_left_prediction_rgb24(HYuvEncContext *s, uint8_t *dst,
159 const uint8_t *src, int w,
160 int *red, int *green, int *blue)
161{
162 int i;
163 int r, g, b;
164 r = *red;
165 g = *green;
166 b = *blue;
167 for (i = 0; i < FFMIN(w, 16); i++) {
168 const int rt = src[i * 3 + 0];
169 const int gt = src[i * 3 + 1];
170 const int bt = src[i * 3 + 2];
171 dst[i * 3 + 0] = rt - r;
172 dst[i * 3 + 1] = gt - g;
173 dst[i * 3 + 2] = bt - b;
174 r = rt;
175 g = gt;
176 b = bt;
177 }
178
179 s->llvidencdsp.diff_bytes(dst + 48, src + 48, src + 48 - 3, w * 3 - 48);
180
181 *red = src[(w - 1) * 3 + 0];
182 *green = src[(w - 1) * 3 + 1];
183 *blue = src[(w - 1) * 3 + 2];
184}
185
187 const uint8_t *src1, const uint8_t *src2,
188 int w, int *left, int *left_top)
189{
190 if (s->bps <= 8) {
191 s->llvidencdsp.sub_median_pred(dst, src1, src2, w , left, left_top);
192 } else {
193 s->hencdsp.sub_hfyu_median_pred_int16((uint16_t *)dst, (const uint16_t *)src1,
194 (const uint16_t *)src2, s->mask, w, left, left_top);
195 }
196}
197
198static int store_table(HYuvEncContext *s, const uint8_t *len, uint8_t *buf)
199{
200 int i;
201 int index = 0;
202 int n = s->vlc_n;
203
204 for (i = 0; i < n;) {
205 int val = len[i];
206 int repeat = 0;
207
208 for (; i < n && len[i] == val && repeat < 255; i++)
209 repeat++;
210
211 av_assert0(val < 32 && val >0 && repeat < 256 && repeat>0);
212 if (repeat > 7) {
213 buf[index++] = val;
214 buf[index++] = repeat;
215 } else {
216 buf[index++] = val | (repeat << 5);
217 }
218 }
219
220 return index;
221}
222
223static int store_huffman_tables(HYuvEncContext *s, uint8_t *buf)
224{
225 int i, ret;
226 int size = 0;
227 int count = 3;
228
229 if (s->version > 2)
230 count = 1 + s->alpha + 2*s->chroma;
231
232 for (i = 0; i < count; i++) {
233 if ((ret = ff_huff_gen_len_table(s->len[i], s->stats[i], s->vlc_n, 0)) < 0)
234 return ret;
235
236 ret = ff_huffyuv_generate_bits_table(s->bits[i], s->len[i], s->vlc_n);
237 if (ret < 0)
238 return ret;
239
240 size += store_table(s, s->len[i], buf + size);
241 }
242 return size;
243}
244
246{
247 HYuvEncContext *s = avctx->priv_data;
248 int i, j;
249 int ret;
251
252 s->avctx = avctx;
253 s->flags = avctx->flags;
254
255 ff_bswapdsp_init(&s->bdsp);
256 ff_llvidencdsp_init(&s->llvidencdsp);
257
258 avctx->extradata = av_mallocz(3*MAX_N + 4);
259 if (!avctx->extradata)
260 return AVERROR(ENOMEM);
261 if (s->flags&AV_CODEC_FLAG_PASS1) {
262#define STATS_OUT_SIZE 21*MAX_N*3 + 4
263 avctx->stats_out = av_mallocz(STATS_OUT_SIZE); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132
264 if (!avctx->stats_out)
265 return AVERROR(ENOMEM);
266 }
267 s->version = 2;
268
270 s->bps = desc->comp[0].depth;
271 s->yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) && desc->nb_components >= 2;
272 s->chroma = desc->nb_components > 2;
273 s->alpha = !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
274 s->chroma_h_shift = desc->log2_chroma_w;
275 s->chroma_v_shift = desc->log2_chroma_h;
276
277 s->mask = (1 << s->bps) - 1;
278 s->vlc_n = FFMIN(1 << s->bps, MAX_VLC_N);
279
280 ff_huffyuvencdsp_init(&s->hencdsp, s->bps, avctx->width >> s->chroma_h_shift);
281
282 switch (avctx->pix_fmt) {
285 if (avctx->width & 1) {
286 av_log(avctx, AV_LOG_ERROR, "Width must be even for this colorspace.\n");
287 return AVERROR(EINVAL);
288 }
289 s->bitstream_bpp = avctx->pix_fmt == AV_PIX_FMT_YUV420P ? 12 : 16;
290 break;
295 case AV_PIX_FMT_GBRP:
296 case AV_PIX_FMT_GBRP9:
301 case AV_PIX_FMT_GRAY8:
306 case AV_PIX_FMT_GBRAP:
331 s->version = 3;
332 break;
333 case AV_PIX_FMT_RGB32:
334 s->bitstream_bpp = 32;
335 break;
336 case AV_PIX_FMT_RGB24:
337 s->bitstream_bpp = 24;
338 break;
339 default:
340 av_unreachable("Already checked via CODEC_PIXFMTS");
341 }
342
343 avctx->bits_per_coded_sample = s->bitstream_bpp;
344 s->decorrelate = s->bitstream_bpp >= 24 && !s->yuv && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR);
345 s->interlaced = avctx->flags & AV_CODEC_FLAG_INTERLACED_ME ? 1 : 0;
346 if (s->context) {
347 if (s->flags & (AV_CODEC_FLAG_PASS1 | AV_CODEC_FLAG_PASS2)) {
348 av_log(avctx, AV_LOG_ERROR,
349 "context=1 is not compatible with "
350 "2 pass huffyuv encoding\n");
351 return AVERROR(EINVAL);
352 }
353 }
354
355 if (avctx->codec->id == AV_CODEC_ID_HUFFYUV) {
356 if (s->interlaced != ( avctx->height > 288 ))
357 av_log(avctx, AV_LOG_INFO,
358 "using huffyuv 2.2.0 or newer interlacing flag\n");
359 }
360
361 if (s->version > 3 && avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
362 av_log(avctx, AV_LOG_ERROR, "Ver > 3 is under development, files encoded with it may not be decodable with future versions!!!\n"
363 "Use vstrict=-2 / -strict -2 to use it anyway.\n");
364 return AVERROR(EINVAL);
365 }
366
367 if (s->bitstream_bpp >= 24 && s->predictor == MEDIAN && s->version <= 2) {
368 av_log(avctx, AV_LOG_ERROR,
369 "Error: RGB is incompatible with median predictor\n");
370 return AVERROR(EINVAL);
371 }
372
373 if (s->predictor == MEDIAN && s->version <= 2 &&
374 (avctx->width < 4 ||
375 AV_CEIL_RSHIFT(avctx->height, s->chroma_v_shift) < 2 + s->interlaced)) {
376 av_log(avctx, AV_LOG_ERROR, "Frame too small for the median predictor\n");
377 return AVERROR(EINVAL);
378 }
379
380 avctx->extradata[0] = s->predictor | (s->decorrelate << 6);
381 avctx->extradata[2] = s->interlaced ? 0x10 : 0x20;
382 if (s->context)
383 avctx->extradata[2] |= 0x40;
384 if (s->version < 3) {
385 avctx->extradata[1] = s->bitstream_bpp;
386 avctx->extradata[3] = 0;
387 } else {
388 avctx->extradata[1] = ((s->bps-1)<<4) | s->chroma_h_shift | (s->chroma_v_shift<<2);
389 if (s->chroma)
390 avctx->extradata[2] |= s->yuv ? 1 : 2;
391 if (s->alpha)
392 avctx->extradata[2] |= 4;
393 avctx->extradata[3] = 1;
394 }
395 avctx->extradata_size = 4;
396
397 if (avctx->stats_in) {
398 char *p = avctx->stats_in;
399
400 for (i = 0; i < 4; i++)
401 for (j = 0; j < s->vlc_n; j++)
402 s->stats[i][j] = 1;
403
404 for (;;) {
405 for (i = 0; i < 4; i++) {
406 char *next;
407
408 for (j = 0; j < s->vlc_n; j++) {
409 s->stats[i][j] += strtol(p, &next, 0);
410 if (next == p) return -1;
411 p = next;
412 }
413 }
414 if (p[0] == 0 || p[1] == 0 || p[2] == 0) break;
415 }
416 } else {
417 for (i = 0; i < 4; i++)
418 for (j = 0; j < s->vlc_n; j++) {
419 int d = FFMIN(j, s->vlc_n - j);
420
421 s->stats[i][j] = 100000000 / (d*d + 1);
422 }
423 }
424
426 if (ret < 0)
427 return ret;
428 avctx->extradata_size += ret;
429
430 if (s->context) {
431 for (i = 0; i < 4; i++) {
432 int pels = avctx->width * avctx->height / (i ? 40 : 10);
433 for (j = 0; j < s->vlc_n; j++) {
434 int d = FFMIN(j, s->vlc_n - j);
435 s->stats[i][j] = pels/(d*d + 1);
436 }
437 }
438 } else {
439 for (i = 0; i < 4; i++)
440 for (j = 0; j < s->vlc_n; j++)
441 s->stats[i][j]= 0;
442 }
443
444 s->picture_number=0;
445
446 for (int i = 0; i < 3; i++) {
447 s->temp[i] = av_malloc(4 * avctx->width + 16);
448 if (!s->temp[i])
449 return AVERROR(ENOMEM);
450 }
451
452 return 0;
453}
454static int encode_422_bitstream(HYuvEncContext *s, int offset, int count)
455{
456 int i;
457 const uint8_t *y = s->temp[0] + offset;
458 const uint8_t *u = s->temp[1] + offset / 2;
459 const uint8_t *v = s->temp[2] + offset / 2;
460
461 if (put_bytes_left(&s->pb, 0) < 2 * 4 * count) {
462 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
463 return -1;
464 }
465
466#define LOAD4\
467 int y0 = y[2 * i];\
468 int y1 = y[2 * i + 1];\
469 int u0 = u[i];\
470 int v0 = v[i];
471
472 count /= 2;
473
474 if (s->flags & AV_CODEC_FLAG_PASS1) {
475 for(i = 0; i < count; i++) {
476 LOAD4;
477 s->stats[0][y0]++;
478 s->stats[1][u0]++;
479 s->stats[0][y1]++;
480 s->stats[2][v0]++;
481 }
482 }
483 if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT)
484 return 0;
485 if (s->context) {
486 for (i = 0; i < count; i++) {
487 LOAD4;
488 s->stats[0][y0]++;
489 put_bits(&s->pb, s->len[0][y0], s->bits[0][y0]);
490 s->stats[1][u0]++;
491 put_bits(&s->pb, s->len[1][u0], s->bits[1][u0]);
492 s->stats[0][y1]++;
493 put_bits(&s->pb, s->len[0][y1], s->bits[0][y1]);
494 s->stats[2][v0]++;
495 put_bits(&s->pb, s->len[2][v0], s->bits[2][v0]);
496 }
497 } else {
498 for(i = 0; i < count; i++) {
499 LOAD4;
500 put_bits(&s->pb, s->len[0][y0], s->bits[0][y0]);
501 put_bits(&s->pb, s->len[1][u0], s->bits[1][u0]);
502 put_bits(&s->pb, s->len[0][y1], s->bits[0][y1]);
503 put_bits(&s->pb, s->len[2][v0], s->bits[2][v0]);
504 }
505 }
506 return 0;
507}
508
509static int encode_plane_bitstream(HYuvEncContext *s, int width, int plane)
510{
511 int count = width/2;
512
513 if (put_bytes_left(&s->pb, 0) < count * s->bps / 2) {
514 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
515 return -1;
516 }
517
518#define LOADEND\
519 int y0 = s->temp[0][width-1];
520#define LOADEND_14\
521 int y0 = s->temp16[0][width-1] & mask;
522#define LOADEND_16\
523 int y0 = s->temp16[0][width-1];
524#define STATEND\
525 s->stats[plane][y0]++;
526#define STATEND_16\
527 s->stats[plane][y0>>2]++;
528#define WRITEEND\
529 put_bits(&s->pb, s->len[plane][y0], s->bits[plane][y0]);
530#define WRITEEND_16\
531 put_bits(&s->pb, s->len[plane][y0>>2], s->bits[plane][y0>>2]);\
532 put_bits(&s->pb, 2, y0&3);
533
534#define LOAD2\
535 int y0 = s->temp[0][2 * i];\
536 int y1 = s->temp[0][2 * i + 1];
537#define LOAD2_14\
538 int y0 = s->temp16[0][2 * i] & mask;\
539 int y1 = s->temp16[0][2 * i + 1] & mask;
540#define LOAD2_16\
541 int y0 = s->temp16[0][2 * i];\
542 int y1 = s->temp16[0][2 * i + 1];
543#define STAT2\
544 s->stats[plane][y0]++;\
545 s->stats[plane][y1]++;
546#define STAT2_16\
547 s->stats[plane][y0>>2]++;\
548 s->stats[plane][y1>>2]++;
549#define WRITE2\
550 put_bits(&s->pb, s->len[plane][y0], s->bits[plane][y0]);\
551 put_bits(&s->pb, s->len[plane][y1], s->bits[plane][y1]);
552#define WRITE2_16\
553 put_bits(&s->pb, s->len[plane][y0>>2], s->bits[plane][y0>>2]);\
554 put_bits(&s->pb, 2, y0&3);\
555 put_bits(&s->pb, s->len[plane][y1>>2], s->bits[plane][y1>>2]);\
556 put_bits(&s->pb, 2, y1&3);
557
558#define ENCODE_PLANE(LOAD, LOADEND, WRITE, WRITEEND, STAT, STATEND) \
559do { \
560 if (s->flags & AV_CODEC_FLAG_PASS1) { \
561 for (int i = 0; i < count; i++) { \
562 LOAD; \
563 STAT; \
564 } \
565 if (width & 1) { \
566 LOADEND; \
567 STATEND; \
568 } \
569 } \
570 if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) \
571 return 0; \
572 \
573 if (s->context) { \
574 for (int i = 0; i < count; i++) { \
575 LOAD; \
576 STAT; \
577 WRITE; \
578 } \
579 if (width & 1) { \
580 LOADEND; \
581 STATEND; \
582 WRITEEND; \
583 } \
584 } else { \
585 for (int i = 0; i < count; i++) { \
586 LOAD; \
587 WRITE; \
588 } \
589 if (width & 1) { \
590 LOADEND; \
591 WRITEEND; \
592 } \
593 } \
594} while (0)
595
596 if (s->bps <= 8) {
598 } else if (s->bps <= 14) {
599 unsigned mask = s->mask;
600
602 } else {
604 }
605#undef LOAD2
606#undef STAT2
607#undef WRITE2
608 return 0;
609}
610
612{
613 int i;
614
615 if (put_bytes_left(&s->pb, 0) < 4 * count) {
616 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
617 return -1;
618 }
619
620#define LOAD2\
621 int y0 = s->temp[0][2 * i];\
622 int y1 = s->temp[0][2 * i + 1];
623#define STAT2\
624 s->stats[0][y0]++;\
625 s->stats[0][y1]++;
626#define WRITE2\
627 put_bits(&s->pb, s->len[0][y0], s->bits[0][y0]);\
628 put_bits(&s->pb, s->len[0][y1], s->bits[0][y1]);
629
630 count /= 2;
631
632 if (s->flags & AV_CODEC_FLAG_PASS1) {
633 for (i = 0; i < count; i++) {
634 LOAD2;
635 STAT2;
636 }
637 }
638 if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT)
639 return 0;
640
641 if (s->context) {
642 for (i = 0; i < count; i++) {
643 LOAD2;
644 STAT2;
645 WRITE2;
646 }
647 } else {
648 for (i = 0; i < count; i++) {
649 LOAD2;
650 WRITE2;
651 }
652 }
653 return 0;
654}
655
656static inline int encode_bgra_bitstream(HYuvEncContext *s, int count, int planes)
657{
658 int i;
659
660 if (put_bytes_left(&s->pb, 0) < 4 * planes * count) {
661 av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
662 return -1;
663 }
664
665#define LOAD_GBRA \
666 int g = s->temp[0][planes == 3 ? 3 * i + 1 : 4 * i + G]; \
667 int b =(s->temp[0][planes == 3 ? 3 * i + 2 : 4 * i + B] - g) & 0xFF;\
668 int r =(s->temp[0][planes == 3 ? 3 * i + 0 : 4 * i + R] - g) & 0xFF;\
669 int a = s->temp[0][planes * i + A];
670
671#define STAT_BGRA \
672 s->stats[0][b]++; \
673 s->stats[1][g]++; \
674 s->stats[2][r]++; \
675 if (planes == 4) \
676 s->stats[2][a]++;
677
678#define WRITE_GBRA \
679 put_bits(&s->pb, s->len[1][g], s->bits[1][g]); \
680 put_bits(&s->pb, s->len[0][b], s->bits[0][b]); \
681 put_bits(&s->pb, s->len[2][r], s->bits[2][r]); \
682 if (planes == 4) \
683 put_bits(&s->pb, s->len[2][a], s->bits[2][a]);
684
685 if ((s->flags & AV_CODEC_FLAG_PASS1) &&
686 (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT)) {
687 for (i = 0; i < count; i++) {
688 LOAD_GBRA;
689 STAT_BGRA;
690 }
691 } else if (s->context || (s->flags & AV_CODEC_FLAG_PASS1)) {
692 for (i = 0; i < count; i++) {
693 LOAD_GBRA;
694 STAT_BGRA;
696 }
697 } else {
698 for (i = 0; i < count; i++) {
699 LOAD_GBRA;
701 }
702 }
703 return 0;
704}
705
707 const AVFrame *p, int *got_packet)
708{
709 HYuvEncContext *s = avctx->priv_data;
710 const int width = avctx->width;
711 const int width2 = avctx->width >> 1;
712 const int height = avctx->height;
713 const int fake_ystride = (1 + s->interlaced) * p->linesize[0];
714 const int fake_ustride = (1 + s->interlaced) * p->linesize[1];
715 const int fake_vstride = (1 + s->interlaced) * p->linesize[2];
716 int i, j, size = 0, ret;
717
718 if ((ret = ff_alloc_packet(avctx, pkt, width * height * 3 * 4 + FF_INPUT_BUFFER_MIN_SIZE)) < 0)
719 return ret;
720
721 if (s->context) {
722 size = store_huffman_tables(s, pkt->data);
723 if (size < 0)
724 return size;
725
726 for (i = 0; i < 4; i++)
727 for (j = 0; j < s->vlc_n; j++)
728 s->stats[i][j] >>= 1;
729 }
730
731 init_put_bits(&s->pb, pkt->data + size, pkt->size - size);
732
733 if (avctx->pix_fmt == AV_PIX_FMT_YUV422P ||
734 avctx->pix_fmt == AV_PIX_FMT_YUV420P) {
735 int lefty, leftu, leftv, y, cy;
736
737 put_bits(&s->pb, 8, leftv = p->data[2][0]);
738 put_bits(&s->pb, 8, lefty = p->data[0][1]);
739 put_bits(&s->pb, 8, leftu = p->data[1][0]);
740 put_bits(&s->pb, 8, p->data[0][0]);
741
742 lefty = sub_left_prediction(s, s->temp[0], p->data[0], width , 0);
743 leftu = sub_left_prediction(s, s->temp[1], p->data[1], width2, 0);
744 leftv = sub_left_prediction(s, s->temp[2], p->data[2], width2, 0);
745
747
748 if (s->predictor==MEDIAN) {
749 int lefttopy, lefttopu, lefttopv;
750 cy = y = 1;
751 if (s->interlaced) {
752 lefty = sub_left_prediction(s, s->temp[0], p->data[0] + p->linesize[0], width , lefty);
753 leftu = sub_left_prediction(s, s->temp[1], p->data[1] + p->linesize[1], width2, leftu);
754 leftv = sub_left_prediction(s, s->temp[2], p->data[2] + p->linesize[2], width2, leftv);
755
757 y++; cy++;
758 }
759
760 lefty = sub_left_prediction(s, s->temp[0], p->data[0] + fake_ystride, 4, lefty);
761 leftu = sub_left_prediction(s, s->temp[1], p->data[1] + fake_ustride, 2, leftu);
762 leftv = sub_left_prediction(s, s->temp[2], p->data[2] + fake_vstride, 2, leftv);
763
764 encode_422_bitstream(s, 0, 4);
765
766 lefttopy = p->data[0][3];
767 lefttopu = p->data[1][1];
768 lefttopv = p->data[2][1];
769 s->llvidencdsp.sub_median_pred(s->temp[0], p->data[0] + 4, p->data[0] + fake_ystride + 4, width - 4, &lefty, &lefttopy);
770 s->llvidencdsp.sub_median_pred(s->temp[1], p->data[1] + 2, p->data[1] + fake_ustride + 2, width2 - 2, &leftu, &lefttopu);
771 s->llvidencdsp.sub_median_pred(s->temp[2], p->data[2] + 2, p->data[2] + fake_vstride + 2, width2 - 2, &leftv, &lefttopv);
773 y++; cy++;
774
775 for (; y < height; y++,cy++) {
776 const uint8_t *ydst, *udst, *vdst;
777
778 if (s->bitstream_bpp == 12) {
779 while (2 * cy > y) {
780 ydst = p->data[0] + p->linesize[0] * y;
781 s->llvidencdsp.sub_median_pred(s->temp[0], ydst - fake_ystride, ydst, width, &lefty, &lefttopy);
783 y++;
784 }
785 if (y >= height) break;
786 }
787 ydst = p->data[0] + p->linesize[0] * y;
788 udst = p->data[1] + p->linesize[1] * cy;
789 vdst = p->data[2] + p->linesize[2] * cy;
790
791 s->llvidencdsp.sub_median_pred(s->temp[0], ydst - fake_ystride, ydst, width, &lefty, &lefttopy);
792 s->llvidencdsp.sub_median_pred(s->temp[1], udst - fake_ustride, udst, width2, &leftu, &lefttopu);
793 s->llvidencdsp.sub_median_pred(s->temp[2], vdst - fake_vstride, vdst, width2, &leftv, &lefttopv);
794
796 }
797 } else {
798 for (cy = y = 1; y < height; y++, cy++) {
799 const uint8_t *ydst, *udst, *vdst;
800
801 /* encode a luma only line & y++ */
802 if (s->bitstream_bpp == 12) {
803 ydst = p->data[0] + p->linesize[0] * y;
804
805 if (s->predictor == PLANE && s->interlaced < y) {
806 s->llvidencdsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width);
807
808 lefty = sub_left_prediction(s, s->temp[0], s->temp[1], width , lefty);
809 } else {
810 lefty = sub_left_prediction(s, s->temp[0], ydst, width , lefty);
811 }
813 y++;
814 if (y >= height) break;
815 }
816
817 ydst = p->data[0] + p->linesize[0] * y;
818 udst = p->data[1] + p->linesize[1] * cy;
819 vdst = p->data[2] + p->linesize[2] * cy;
820
821 if (s->predictor == PLANE && s->interlaced < cy) {
822 s->llvidencdsp.diff_bytes(s->temp[1], ydst, ydst - fake_ystride, width);
823 s->llvidencdsp.diff_bytes(s->temp[2], udst, udst - fake_ustride, width2);
824 s->llvidencdsp.diff_bytes(s->temp[2] + width2, vdst, vdst - fake_vstride, width2);
825
826 lefty = sub_left_prediction(s, s->temp[0], s->temp[1], width , lefty);
827 leftu = sub_left_prediction(s, s->temp[1], s->temp[2], width2, leftu);
828 leftv = sub_left_prediction(s, s->temp[2], s->temp[2] + width2, width2, leftv);
829 } else {
830 lefty = sub_left_prediction(s, s->temp[0], ydst, width , lefty);
831 leftu = sub_left_prediction(s, s->temp[1], udst, width2, leftu);
832 leftv = sub_left_prediction(s, s->temp[2], vdst, width2, leftv);
833 }
834
836 }
837 }
838 } else if(avctx->pix_fmt == AV_PIX_FMT_RGB32) {
839 const uint8_t *data = p->data[0] + (height - 1) * p->linesize[0];
840 const int stride = -p->linesize[0];
841 const int fake_stride = -fake_ystride;
842 int leftr, leftg, leftb, lefta;
843
844 put_bits(&s->pb, 8, lefta = data[A]);
845 put_bits(&s->pb, 8, leftr = data[R]);
846 put_bits(&s->pb, 8, leftg = data[G]);
847 put_bits(&s->pb, 8, leftb = data[B]);
848
849 sub_left_prediction_bgr32(s, s->temp[0], data + 4, width - 1,
850 &leftr, &leftg, &leftb, &lefta);
852
853 for (int y = 1; y < height; y++) {
854 const uint8_t *dst = data + y*stride;
855 if (s->predictor == PLANE && s->interlaced < y) {
856 s->llvidencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride, width * 4);
857 sub_left_prediction_bgr32(s, s->temp[0], s->temp[1], width,
858 &leftr, &leftg, &leftb, &lefta);
859 } else {
861 &leftr, &leftg, &leftb, &lefta);
862 }
864 }
865 } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
866 const uint8_t *data = p->data[0] + (height - 1) * p->linesize[0];
867 const int stride = -p->linesize[0];
868 const int fake_stride = -fake_ystride;
869 int leftr, leftg, leftb;
870
871 put_bits(&s->pb, 8, leftr = data[0]);
872 put_bits(&s->pb, 8, leftg = data[1]);
873 put_bits(&s->pb, 8, leftb = data[2]);
874 put_bits(&s->pb, 8, 0);
875
876 sub_left_prediction_rgb24(s, s->temp[0], data + 3, width - 1,
877 &leftr, &leftg, &leftb);
879
880 for (int y = 1; y < height; y++) {
881 const uint8_t *dst = data + y * stride;
882 if (s->predictor == PLANE && s->interlaced < y) {
883 s->llvidencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride,
884 width * 3);
885 sub_left_prediction_rgb24(s, s->temp[0], s->temp[1], width,
886 &leftr, &leftg, &leftb);
887 } else {
889 &leftr, &leftg, &leftb);
890 }
892 }
893 } else if (s->version > 2) {
894 int plane;
895 for (plane = 0; plane < 1 + 2*s->chroma + s->alpha; plane++) {
896 int left, y;
897 int w = width;
898 int h = height;
899 int fake_stride = fake_ystride;
900
901 if (s->chroma && (plane == 1 || plane == 2)) {
902 w >>= s->chroma_h_shift;
903 h >>= s->chroma_v_shift;
904 fake_stride = plane == 1 ? fake_ustride : fake_vstride;
905 }
906
907 left = sub_left_prediction(s, s->temp[0], p->data[plane], w , 0);
908
909 encode_plane_bitstream(s, w, plane);
910
911 if (s->predictor==MEDIAN) {
912 int lefttop;
913 y = 1;
914 if (s->interlaced && h > 1) {
915 left = sub_left_prediction(s, s->temp[0], p->data[plane] + p->linesize[plane], w , left);
916
917 encode_plane_bitstream(s, w, plane);
918 y++;
919 }
920
921 lefttop = READ_LOWBYTE(p->data[plane], s->bps);
922
923 for (; y < h; y++) {
924 const uint8_t *dst = p->data[plane] + p->linesize[plane] * y;
925
926 sub_median_prediction(s, s->temp[0], dst - fake_stride, dst, w , &left, &lefttop);
927
928 encode_plane_bitstream(s, w, plane);
929 }
930 } else {
931 for (y = 1; y < h; y++) {
932 const uint8_t *dst = p->data[plane] + p->linesize[plane] * y;
933
934 if (s->predictor == PLANE && s->interlaced < y) {
935 diff_bytes(s, s->temp[1], dst, dst - fake_stride, w);
936
937 left = sub_left_prediction(s, s->temp[0], s->temp[1], w , left);
938 } else {
939 left = sub_left_prediction(s, s->temp[0], dst, w , left);
940 }
941
942 encode_plane_bitstream(s, w, plane);
943 }
944 }
945 }
946 } else {
947 av_log(avctx, AV_LOG_ERROR, "Format not supported!\n");
948 }
949
950 size += (put_bits_count(&s->pb) + 31) / 8;
951 put_bits(&s->pb, 16, 0);
952 put_bits(&s->pb, 15, 0);
953 size /= 4;
954
955 if ((s->flags & AV_CODEC_FLAG_PASS1) && (s->picture_number & 31) == 0) {
956 int j;
957 char *p = avctx->stats_out;
958 char *end = p + STATS_OUT_SIZE;
959 for (i = 0; i < 4; i++) {
960 for (j = 0; j < s->vlc_n; j++) {
961 snprintf(p, end-p, "%"PRIu64" ", s->stats[i][j]);
962 p += strlen(p);
963 s->stats[i][j]= 0;
964 }
965 snprintf(p, end-p, "\n");
966 p++;
967 if (end <= p)
968 return AVERROR(ENOMEM);
969 }
970 } else if (avctx->stats_out)
971 avctx->stats_out[0] = '\0';
972 if (!(s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT)) {
973 flush_put_bits(&s->pb);
974 s->bdsp.bswap_buf((uint32_t *) pkt->data, (uint32_t *) pkt->data, size);
975 }
976
977 s->picture_number++;
978
979 pkt->size = size * 4;
980 *got_packet = 1;
981
982 return 0;
983}
984
986{
987 HYuvEncContext *s = avctx->priv_data;
988
989 av_freep(&avctx->stats_out);
990
991 for (int i = 0; i < 3; i++)
992 av_freep(&s->temp[i]);
993
994 return 0;
995}
996
997#define OFFSET(x) offsetof(HYuvEncContext, x)
998#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
999
1000static const AVOption options[] = {
1001 /* ffvhuff-only options */
1002 { "context", "Set per-frame huffman tables", OFFSET(context), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
1003 /* Common options */
1004 { "non_deterministic", "Allow multithreading for e.g. context=1 at the expense of determinism",
1005 OFFSET(non_determ), AV_OPT_TYPE_BOOL, { .i64 = 0 },
1006 0, 1, VE },
1007 { "pred", "Prediction method", OFFSET(predictor), AV_OPT_TYPE_INT, { .i64 = LEFT }, LEFT, MEDIAN, VE, .unit = "pred" },
1008 { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LEFT }, INT_MIN, INT_MAX, VE, .unit = "pred" },
1009 { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PLANE }, INT_MIN, INT_MAX, VE, .unit = "pred" },
1010 { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MEDIAN }, INT_MIN, INT_MAX, VE, .unit = "pred" },
1011 { NULL },
1012};
1013
1014static const AVClass normal_class = {
1015 .class_name = "huffyuv",
1016 .item_name = av_default_item_name,
1017 .option = options + 1,
1018 .version = LIBAVUTIL_VERSION_INT,
1019};
1020
1022 .p.name = "huffyuv",
1023 CODEC_LONG_NAME("Huffyuv / HuffYUV"),
1024 .p.type = AVMEDIA_TYPE_VIDEO,
1025 .p.id = AV_CODEC_ID_HUFFYUV,
1026 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
1028 .priv_data_size = sizeof(HYuvEncContext),
1029 .init = encode_init,
1031 .close = encode_end,
1032 .p.priv_class = &normal_class,
1034 .color_ranges = AVCOL_RANGE_MPEG,
1035 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1036};
1037
1038#if CONFIG_FFVHUFF_ENCODER
1039static const AVClass ff_class = {
1040 .class_name = "ffvhuff",
1041 .item_name = av_default_item_name,
1042 .option = options,
1043 .version = LIBAVUTIL_VERSION_INT,
1044};
1045
1047 .p.name = "ffvhuff",
1048 CODEC_LONG_NAME("Huffyuv FFmpeg variant"),
1049 .p.type = AVMEDIA_TYPE_VIDEO,
1050 .p.id = AV_CODEC_ID_FFVHUFF,
1051 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
1053 .priv_data_size = sizeof(HYuvEncContext),
1054 .init = encode_init,
1056 .close = encode_end,
1057 .p.priv_class = &ff_class,
1074 .color_ranges = AVCOL_RANGE_MPEG,
1075 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1076};
1077#endif
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:97
static double val(void *priv, double ch)
Definition aeval.c:77
const FFCodec ff_huffyuv_encoder
const FFCodec ff_ffvhuff_encoder
#define VE
Definition amfenc_av1.c:30
#define A(x)
Definition vpx_arith.h:28
static av_cold int encode_init(AVCodecContext *avctx)
Definition asvenc.c:373
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
Definition avassert.h:109
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
Libavcodec external API header.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define LEFT
Definition cdgraphics.c:168
#define CODEC_PIXFMTS(...)
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define AV_CEIL_RSHIFT(a, b)
Definition common.h:60
#define NULL
Definition coverity.c:32
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
Definition defs.h:62
static AVPacket * pkt
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:613
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
Definition encode.c:63
#define FF_INPUT_BUFFER_MIN_SIZE
Used by some encoders as upper bound for the length of headers.
Definition encode.h:34
static void predictor(uint8_t *src, ptrdiff_t size)
Definition exrenc.c:170
static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame, AVPacket *pkt)
Definition ffmpeg_enc.c:683
int ret
Definition ffplay.c:391
#define STATS_OUT_SIZE
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
#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:147
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
Definition avcodec.h:294
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
Definition avcodec.h:290
#define AV_CODEC_FLAG_INTERLACED_ME
interlaced motion estimation
Definition avcodec.h:331
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition codec.h:98
#define AV_CODEC_FLAG2_NO_OUTPUT
Skip bitstream encoding.
Definition avcodec.h:341
@ AV_CODEC_ID_FFVHUFF
Definition codec_id.h:117
@ AV_CODEC_ID_HUFFYUV
Definition codec_id.h:75
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_INFO
Standard information.
Definition log.h:221
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:247
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
int index
Definition gxfenc.c:90
int a
const pixel * src2
int ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats, int stats_size, int skip0)
Definition huffman.c:63
huffman tree builder and VLC generator
int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int n)
Definition huffyuv.c:40
huffyuv codec for libavcodec.
#define B
Definition huffyuv.h:42
#define MAX_N
Definition huffyuv.h:49
#define R
Definition huffyuv.h:44
#define MAX_VLC_N
Definition huffyuv.h:50
@ PLANE
Definition huffyuv.h:54
#define READ_LOWBYTE(plane, bps)
Definition huffyuv.h:58
#define G
Definition huffyuv.h:43
#define WRITE2_16
static void diff_bytes(HYuvEncContext *s, uint8_t *dst, const uint8_t *src0, const uint8_t *src1, int w)
Definition huffyuvenc.c:81
#define STAT2_16
static int store_table(HYuvEncContext *s, const uint8_t *len, uint8_t *buf)
Definition huffyuvenc.c:198
static void sub_median_prediction(HYuvEncContext *s, uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top)
Definition huffyuvenc.c:186
#define LOAD2
#define STAT2
static int sub_left_prediction(HYuvEncContext *s, uint8_t *dst, const uint8_t *src, int w, int left)
Definition huffyuvenc.c:91
#define STATEND_16
#define LOAD_GBRA
static void sub_left_prediction_bgr32(HYuvEncContext *s, uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha)
Definition huffyuvenc.c:122
#define LOADEND_16
#define STAT_BGRA
#define LOAD2_14
static int store_huffman_tables(HYuvEncContext *s, uint8_t *buf)
Definition huffyuvenc.c:223
static int encode_bgra_bitstream(HYuvEncContext *s, int count, int planes)
Definition huffyuvenc.c:656
static av_cold int encode_init(AVCodecContext *avctx)
Definition huffyuvenc.c:245
#define LOADEND_14
#define WRITE2
static int encode_plane_bitstream(HYuvEncContext *s, int width, int plane)
Definition huffyuvenc.c:509
static const AVClass normal_class
#define WRITEEND_16
static int encode_gray_bitstream(HYuvEncContext *s, int count)
Definition huffyuvenc.c:611
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *p, int *got_packet)
Definition huffyuvenc.c:706
#define LOAD4
static av_cold int encode_end(AVCodecContext *avctx)
Definition huffyuvenc.c:985
static void sub_left_prediction_rgb24(HYuvEncContext *s, uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue)
Definition huffyuvenc.c:158
#define WRITE_GBRA
#define OFFSET(x)
Definition huffyuvenc.c:997
#define LOAD2_16
#define LOADEND
#define ENCODE_PLANE(LOAD, LOADEND, WRITE, WRITEEND, STAT, STATEND)
static int encode_422_bitstream(HYuvEncContext *s, int offset, int count)
Definition huffyuvenc.c:454
#define WRITEEND
#define STATEND
static const int16_t alpha[]
Definition ilbcdata.h:55
#define r
Definition input.c:42
#define b
Definition input.c:43
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition j2kenc.c:154
unsigned offset
Definition libaomenc.c:763
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
Definition bswapdsp.c:37
#define u(width, name, range_min, range_max)
Definition cbs_apv.c:68
av_cold void ff_huffyuvencdsp_init(HuffYUVEncDSPContext *c, int bpp, int width)
#define av_cold
Definition attributes.h:117
const char * desc
Definition libsvtav1.c:83
static const struct @257111027162314367033347246032313251342043035002 planes[]
uint8_t w
Definition llvidencdsp.c:39
av_cold void ff_llvidencdsp_init(LLVidEncDSPContext *c)
static const uint16_t mask[17]
Definition lzw.c:38
#define FFMIN(a, b)
Definition macros.h:49
Memory handling functions.
const char data[16]
Definition mxf.c:149
#define av_malloc(s)
Definition ops_static.c:52
AVOptions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3484
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition pixdesc.h:147
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition pixdesc.h:136
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition pixdesc.h:132
#define AV_PIX_FMT_YUV420P16
Definition pixfmt.h:559
#define AV_PIX_FMT_YUV444P12
Definition pixfmt.h:555
#define AV_PIX_FMT_YUV444P9
Definition pixfmt.h:547
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:548
#define AV_PIX_FMT_GBRP9
Definition pixfmt.h:566
#define AV_PIX_FMT_YUV422P9
Definition pixfmt.h:546
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition pixfmt.h:775
#define AV_PIX_FMT_YUVA444P10
Definition pixfmt.h:601
#define AV_PIX_FMT_YUVA420P16
Definition pixfmt.h:604
#define AV_PIX_FMT_YUV420P12
Definition pixfmt.h:552
#define AV_PIX_FMT_YUVA420P10
Definition pixfmt.h:599
#define AV_PIX_FMT_YUVA422P9
Definition pixfmt.h:597
#define AV_PIX_FMT_YUV422P12
Definition pixfmt.h:553
#define AV_PIX_FMT_GBRP10
Definition pixfmt.h:567
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:549
#define AV_PIX_FMT_GBRP12
Definition pixfmt.h:568
#define AV_PIX_FMT_YUV420P9
Definition pixfmt.h:545
#define AV_PIX_FMT_YUVA420P9
Definition pixfmt.h:596
#define AV_PIX_FMT_YUVA422P10
Definition pixfmt.h:600
#define AV_PIX_FMT_YUV420P14
Definition pixfmt.h:556
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition pixfmt.h:75
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition pixfmt.h:108
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ 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_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition pixfmt.h:174
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition pixfmt.h:212
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition pixfmt.h:173
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165
#define AV_PIX_FMT_YUV422P14
Definition pixfmt.h:557
#define AV_PIX_FMT_YUV422P16
Definition pixfmt.h:560
#define AV_PIX_FMT_GRAY16
Definition pixfmt.h:531
#define AV_PIX_FMT_YUVA444P16
Definition pixfmt.h:606
#define AV_PIX_FMT_YUVA422P16
Definition pixfmt.h:605
#define AV_PIX_FMT_GBRP16
Definition pixfmt.h:570
#define AV_PIX_FMT_YUV444P14
Definition pixfmt.h:558
#define AV_PIX_FMT_YUVA444P9
Definition pixfmt.h:598
#define AV_PIX_FMT_GBRP14
Definition pixfmt.h:569
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:561
#define AV_PIX_FMT_RGB32
Definition pixfmt.h:520
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:551
bitstream writer API
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition put_bits.h:62
static int put_bits_count(PutBitContext *s)
Definition put_bits.h:90
static int put_bytes_left(const PutBitContext *s, int round_up)
Definition put_bits.h:145
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition put_bits.h:153
#define MEDIAN(x)
Describe the class of an AVClass context structure.
Definition log.h:76
main external API structure.
Definition avcodec.h:443
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition avcodec.h:644
int width
picture width / height.
Definition avcodec.h:605
char * stats_out
pass1 encoding statistics output buffer
Definition avcodec.h:1335
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
Definition avcodec.h:1381
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
Definition avcodec.h:1343
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition avcodec.h:1574
const struct AVCodec * codec
Definition avcodec.h:452
int flags
AV_CODEC_FLAG_*.
Definition avcodec.h:500
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
Definition avcodec.h:526
int extradata_size
Definition avcodec.h:527
void * priv_data
Definition avcodec.h:470
enum AVCodecID id
Definition codec.h:189
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
AVOption.
Definition opt.h:428
This structure stores compressed data.
Definition packet.h:587
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
uint8_t len[4][MAX_VLC_N]
Definition huffyuvenc.c:73
uint64_t stats[4][MAX_VLC_N]
Definition huffyuvenc.c:72
AVCodecContext * avctx
Definition huffyuvenc.c:48
PutBitContext pb
Definition huffyuvenc.c:49
uint16_t * temp16[3]
Definition huffyuvenc.c:70
unsigned mask
Definition huffyuvenc.c:57
HuffYUVEncDSPContext hencdsp
Definition huffyuvenc.c:76
BswapDSPContext bdsp
Definition huffyuvenc.c:75
LLVidEncDSPContext llvidencdsp
Definition huffyuvenc.c:77
uint32_t bits[4][MAX_VLC_N]
Definition huffyuvenc.c:74
uint8_t * temp[3]
Definition huffyuvenc.c:69
#define stride
#define av_mallocz(s)
#define av_freep(p)
#define av_log(a,...)
#define src1
Definition h264pred.c:141
#define src0
Definition h264pred.c:140
#define src
Definition vp8dsp.c:248
#define height
Definition dsp.h:99
#define width
Definition dsp.h:99
int size
const char * g
Definition vf_curves.c:128
else temp
Definition vf_mcdeint.c:275
int len