43 for (i = 0; i < w; i++) {
44 const int temp = src[i];
50 for (i = 0; i < 16; i++) {
51 const int temp = src[i];
62 int *red,
int *green,
int *blue,
72 for (i = 0; i <
FFMIN(w, 4); i++) {
73 const int rt = src[i * 4 +
R];
74 const int gt = src[i * 4 +
G];
75 const int bt = src[i * 4 +
B];
76 const int at = src[i * 4 +
A];
77 dst[i * 4 +
R] = rt -
r;
78 dst[i * 4 +
G] = gt -
g;
79 dst[i * 4 +
B] = bt -
b;
80 dst[i * 4 +
A] = at -
a;
89 *red = src[(w - 1) * 4 +
R];
90 *green = src[(w - 1) * 4 +
G];
91 *blue = src[(w - 1) * 4 +
B];
92 *alpha = src[(w - 1) * 4 +
A];
97 int *red,
int *green,
int *blue)
104 for (i = 0; i <
FFMIN(w, 16); i++) {
105 const int rt = src[i * 3 + 0];
106 const int gt = src[i * 3 + 1];
107 const int bt = src[i * 3 + 2];
108 dst[i * 3 + 0] = rt -
r;
109 dst[i * 3 + 1] = gt -
g;
110 dst[i * 3 + 2] = bt -
b;
118 *red = src[(w - 1) * 3 + 0];
119 *green = src[(w - 1) * 3 + 1];
120 *blue = src[(w - 1) * 3 + 2];
128 for (i = 0; i < 256;) {
132 for (; i < 256 && len[i] == val && repeat < 255; i++)
135 assert(val < 32 && val >0 && repeat<256 && repeat>0);
138 buf[index++] = repeat;
140 buf[index++] = val | (repeat << 5);
162 #if FF_API_CODED_FRAME 168 #if FF_API_PRIVATE_OPT 196 #if FF_API_PRIVATE_OPT 206 "context=1 is not compatible with " 207 "2 pass huffyuv encoding\n");
215 "Error: YV12 is not supported by huffyuv; use " 216 "vcodec=ffvhuff or format=422p\n");
219 #if FF_API_PRIVATE_OPT 222 "Error: per-frame huffman tables are not supported " 223 "by huffyuv; use vcodec=ffvhuff\n");
229 "using huffyuv 2.2.0 or newer interlacing flag\n");
234 "Error: RGB is incompatible with median predictor\n");
249 for (i = 0; i < 3; i++)
250 for (j = 0; j < 256; j++)
254 for (i = 0; i < 3; i++) {
257 for (j = 0; j < 256; j++) {
258 s->
stats[i][j] += strtol(p, &next, 0);
259 if (next == p)
return -1;
263 if (p[0] == 0 || p[1] == 0 || p[2] == 0)
break;
266 for (i = 0; i < 3; i++)
267 for (j = 0; j < 256; j++) {
268 int d =
FFMIN(j, 256 - j);
270 s->
stats[i][j] = 100000000 / (d + 1);
274 for (i = 0; i < 3; i++) {
286 for (i = 0; i < 3; i++) {
288 for (j = 0; j < 256; j++) {
289 int d =
FFMIN(j, 256 - j);
290 s->
stats[i][j] = pels/(d + 1);
294 for (i = 0; i < 3; i++)
295 for (j = 0; j < 256; j++)
319 int y1 = y[2 * i + 1];\ 326 for(i = 0; i < count; i++) {
337 for (i = 0; i < count; i++) {
349 for(i = 0; i < count; i++) {
370 int y0 = s->temp[0][2 * i];\ 371 int y1 = s->temp[0][2 * i + 1]; 376 put_bits(&s->pb, s->len[0][y0], s->bits[0][y0]);\ 377 put_bits(&s->pb, s->len[0][y1], s->bits[0][y1]); 382 for (i = 0; i < count; i++) {
391 for (i = 0; i < count; i++) {
397 for (i = 0; i < count; i++) {
410 4 * planes * count) {
416 int g = s->temp[0][planes == 3 ? 3 * i + 1 : 4 * i + G]; \ 417 int b = s->temp[0][planes == 3 ? 3 * i + 2 : 4 * i + B] - g & 0xFF; \ 418 int r = s->temp[0][planes == 3 ? 3 * i + 0 : 4 * i + R] - g & 0xFF; \ 419 int a = s->temp[0][planes * i + A]; 429 put_bits(&s->pb, s->len[1][g], s->bits[1][g]); \ 430 put_bits(&s->pb, s->len[0][b], s->bits[0][b]); \ 431 put_bits(&s->pb, s->len[2][r], s->bits[2][r]); \ 433 put_bits(&s->pb, s->len[2][a], s->bits[2][a]); 437 for (i = 0; i < count; i++) {
442 for (i = 0; i < count; i++) {
448 for (i = 0; i < count; i++) {
457 const AVFrame *pict,
int *got_packet)
461 const int width2 = s->
width>>1;
466 const AVFrame *
const p = pict;
467 int i, j,
size = 0, ret;
476 for (i = 0; i < 3; i++) {
483 for (i = 0; i < 3; i++)
484 for (j = 0; j < 256; j++)
485 s->
stats[i][j] >>= 1;
492 int lefty, leftu, leftv, y, cy;
506 int lefttopy, lefttopu, lefttopv;
523 lefttopy = p->
data[0][3];
524 lefttopu = p->
data[1][1];
525 lefttopv = p->
data[2][1];
532 for (; y <
height; y++,cy++) {
542 if (y >= height)
break;
555 for (cy = y = 1; y <
height; y++, cy++) {
571 if (y >= height)
break;
598 const int fake_stride = -fake_ystride;
600 int leftr, leftg, leftb, lefta;
608 &leftr, &leftg, &leftb, &lefta);
611 for (y = 1; y < s->
height; y++) {
616 &leftr, &leftg, &leftb, &lefta);
619 &leftr, &leftg, &leftb, &lefta);
626 const int fake_stride = -fake_ystride;
628 int leftr, leftg, leftb;
636 &leftr, &leftg, &leftb);
639 for (y = 1; y < s->
height; y++) {
645 &leftr, &leftg, &leftb);
648 &leftr, &leftg, &leftb);
665 char *end = p + 1024*30;
666 for (i = 0; i < 3; i++) {
667 for (j = 0; j < 256; j++) {
668 snprintf(p, end-p,
"%"PRIu64
" ", s->
stats[i][j]);
672 snprintf(p, end-p,
"\n");
684 pkt->
size = size * 4;
703 #define OFFSET(x) offsetof(HYuvContext, x) 704 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 706 #define HUFF_CLASS(variant) \ 707 static const AVClass variant ## _class = { \ 708 .class_name = # variant, \ 709 .item_name = av_default_item_name, \ 710 .option = variant ## _options, \ 711 .version = LIBAVUTIL_VERSION_INT, \ 714 #define FF_HUFFYUV_COMMON_OPTS \ 715 { "pred", "Prediction method", OFFSET(predictor), AV_OPT_TYPE_INT, { .i64 = LEFT }, LEFT, MEDIAN, VE, "pred" }, \ 716 { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LEFT }, INT_MIN, INT_MAX, VE, "pred" }, \ 717 { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PLANE }, INT_MIN, INT_MAX, VE, "pred" }, \ 718 { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MEDIAN }, INT_MIN, INT_MAX, VE, "pred" } 733 .priv_class = &huffyuv_class,
745 #if CONFIG_FFVHUFF_ENCODER 746 static const AVOption ffhuffyuv_options[] = {
760 .priv_class = &ffhuffyuv_class,
#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_CODEC_FLAG_INTERLACED_ME
interlaced motion estimation
const struct AVCodec * codec
This structure describes decoded (raw) audio or video data.
static av_cold int encode_init(AVCodecContext *avctx)
static int sub_left_prediction(HYuvContext *s, uint8_t *dst, uint8_t *src, int w, int left)
void(* diff_bytes)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w)
packed RGB 8:8:8, 24bpp, RGBRGB...
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
void ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
void ff_huffyuv_common_end(HYuvContext *s)
av_cold void ff_huffyuvencdsp_init(HuffYUVEncDSPContext *c)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
attribute_deprecated int context_model
static void sub_left_prediction_rgb24(HYuvContext *s, uint8_t *dst, uint8_t *src, int w, int *red, int *green, int *blue)
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
char * stats_out
pass1 encoding statistics output buffer
#define AV_INPUT_BUFFER_MIN_SIZE
minimum encoding buffer size Used to avoid some checks during header writing.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
av_cold int ff_huffyuv_alloc_temp(HYuvContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int flags
AV_CODEC_FLAG_*.
const char * name
Name of the codec implementation.
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
huffyuv codec for libavcodec.
int flags
A combination of AV_PKT_FLAG values.
static int put_bits_count(PutBitContext *s)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
enum AVPictureType pict_type
Picture type of the frame.
AVCodec ff_huffyuv_encoder
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
static const AVOption huffyuv_options[]
static av_cold int encode_end(AVCodecContext *avctx)
#define AV_LOG_INFO
Standard information.
void(* sub_hfyu_median_pred)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top)
Subtract HuffYUV's variant of median prediction.
Libavcodec external API header.
static int encode_422_bitstream(HYuvContext *s, int offset, int count)
attribute_deprecated int prediction_method
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
huffman tree builder and VLC generator
static int encode_bgra_bitstream(HYuvContext *s, int count, int planes)
static enum AVPixelFormat pix_fmts[]
HuffYUVEncDSPContext hencdsp
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static int store_table(HYuvContext *s, const uint8_t *len, uint8_t *buf)
static void sub_left_prediction_bgr32(HYuvContext *s, uint8_t *dst, uint8_t *src, int w, int *red, int *green, int *blue, int *alpha)
#define AV_CODEC_FLAG2_NO_OUTPUT
Skip bitstream encoding.
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
static int encode_gray_bitstream(HYuvContext *s, int count)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static av_cold int init(AVCodecParserContext *s)
av_cold void ff_huffyuv_common_init(AVCodecContext *avctx)
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
#define FF_ENABLE_DEPRECATION_WARNINGS
int key_frame
1 -> keyframe, 0-> not
int flags2
AV_CODEC_FLAG2_*.
#define FF_HUFFYUV_COMMON_OPTS
AVPixelFormat
Pixel format.
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define HUFF_CLASS(variant)
int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table)