40 for (i = 0; i < w; i++) {
41 const int temp = src[i];
47 for (i = 0; i < 16; i++) {
48 const int temp = src[i];
59 int *red,
int *green,
int *blue,
69 for (i = 0; i <
FFMIN(w, 4); i++) {
70 const int rt = src[i * 4 +
R];
71 const int gt = src[i * 4 +
G];
72 const int bt = src[i * 4 +
B];
73 const int at = src[i * 4 +
A];
74 dst[i * 4 +
R] = rt -
r;
75 dst[i * 4 +
G] = gt -
g;
76 dst[i * 4 +
B] = bt -
b;
77 dst[i * 4 +
A] = at -
a;
86 *red = src[(w - 1) * 4 +
R];
87 *green = src[(w - 1) * 4 +
G];
88 *blue = src[(w - 1) * 4 +
B];
89 *alpha = src[(w - 1) * 4 +
A];
94 int *red,
int *green,
int *blue)
101 for (i = 0; i <
FFMIN(w, 16); i++) {
102 const int rt = src[i * 3 + 0];
103 const int gt = src[i * 3 + 1];
104 const int bt = src[i * 3 + 2];
105 dst[i * 3 + 0] = rt -
r;
106 dst[i * 3 + 1] = gt -
g;
107 dst[i * 3 + 2] = bt -
b;
113 s->
dsp.
diff_bytes(dst + 48, src + 48, src + 48 - 3, w * 3 - 48);
115 *red = src[(w - 1) * 3 + 0];
116 *green = src[(w - 1) * 3 + 1];
117 *blue = src[(w - 1) * 3 + 2];
125 for (i = 0; i < 256;) {
129 for (; i < 256 && len[i] == val && repeat < 255; i++)
132 av_assert0(val < 32 && val >0 && repeat<256 && repeat>0);
135 buf[index++] = repeat;
137 buf[index++] = val | (repeat << 5);
188 "context=1 is not compatible with "
189 "2 pass huffyuv encoding\n");
197 "Error: YV12 is not supported by huffyuv; use "
198 "vcodec=ffvhuff or format=422p\n");
203 "Error: per-frame huffman tables are not supported "
204 "by huffyuv; use vcodec=ffvhuff\n");
209 "using huffyuv 2.2.0 or newer interlacing flag\n");
214 "Error: RGB is incompatible with median predictor\n");
229 for (i = 0; i < 3; i++)
230 for (j = 0; j < 256; j++)
234 for (i = 0; i < 3; i++) {
237 for (j = 0; j < 256; j++) {
238 s->
stats[i][j] += strtol(p, &next, 0);
239 if (next == p)
return -1;
243 if (p[0] == 0 || p[1] == 0 || p[2] == 0)
break;
246 for (i = 0; i < 3; i++)
247 for (j = 0; j < 256; j++) {
248 int d =
FFMIN(j, 256 - j);
250 s->
stats[i][j] = 100000000 / (d + 1);
254 for (i = 0; i < 3; i++) {
266 for (i = 0; i < 3; i++) {
268 for (j = 0; j < 256; j++) {
269 int d =
FFMIN(j, 256 - j);
270 s->
stats[i][j] = pels/(d + 1);
274 for (i = 0; i < 3; i++)
275 for (j = 0; j < 256; j++)
302 int y1 = y[2 * i + 1];\
309 for(i = 0; i <
count; i++) {
320 for (i = 0; i <
count; i++) {
332 for(i = 0; i <
count; i++) {
353 int y0 = s->temp[0][2 * i];\
354 int y1 = s->temp[0][2 * i + 1];
359 put_bits(&s->pb, s->len[0][y0], s->bits[0][y0]);\
360 put_bits(&s->pb, s->len[0][y1], s->bits[0][y1]);
365 for (i = 0; i <
count; i++) {
374 for (i = 0; i <
count; i++) {
380 for (i = 0; i <
count; i++) {
393 4 * planes * count) {
399 int g = s->temp[0][planes == 3 ? 3 * i + 1 : 4 * i + G]; \
400 int b =(s->temp[0][planes == 3 ? 3 * i + 2 : 4 * i + B] - g) & 0xFF;\
401 int r =(s->temp[0][planes == 3 ? 3 * i + 0 : 4 * i + R] - g) & 0xFF;\
402 int a = s->temp[0][planes * i + A];
412 put_bits(&s->pb, s->len[1][g], s->bits[1][g]); \
413 put_bits(&s->pb, s->len[0][b], s->bits[0][b]); \
414 put_bits(&s->pb, s->len[2][r], s->bits[2][r]); \
416 put_bits(&s->pb, s->len[2][a], s->bits[2][a]);
420 for (i = 0; i <
count; i++) {
425 for (i = 0; i <
count; i++) {
431 for (i = 0; i <
count; i++) {
440 const AVFrame *pict,
int *got_packet)
444 const int width2 = s->
width>>1;
460 for (i = 0; i < 3; i++) {
467 for (i = 0; i < 3; i++)
468 for (j = 0; j < 256; j++)
469 s->
stats[i][j] >>= 1;
476 int lefty, leftu, leftv,
y, cy;
490 int lefttopy, lefttopu, lefttopv;
507 lefttopy = p->
data[0][3];
508 lefttopu = p->
data[1][1];
509 lefttopv = p->
data[2][1];
516 for (; y <
height; y++,cy++) {
526 if (y >= height)
break;
539 for (cy = y = 1; y <
height; y++, cy++) {
555 if (y >= height)
break;
582 const int fake_stride = -fake_ystride;
584 int leftr, leftg, leftb, lefta;
592 &leftr, &leftg, &leftb, &lefta);
600 &leftr, &leftg, &leftb, &lefta);
603 &leftr, &leftg, &leftb, &lefta);
610 const int fake_stride = -fake_ystride;
612 int leftr, leftg, leftb;
620 &leftr, &leftg, &leftb);
629 &leftr, &leftg, &leftb);
632 &leftr, &leftg, &leftb);
649 char *
end = p + 1024*30;
650 for (i = 0; i < 3; i++) {
651 for (j = 0; j < 256; j++) {
668 pkt->
size = size * 4;
687 #if CONFIG_HUFFYUV_ENCODER
704 #if CONFIG_FFVHUFF_ENCODER
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and/or allocate data.
const char const char void * val
This structure describes decoded (raw) audio or video data.
static av_cold int encode_init(AVCodecContext *avctx)
#define CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
#define CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
static av_cold int init(AVCodecContext *avctx)
packed RGB 8:8:8, 24bpp, RGBRGB...
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
int context_model
context model
static const uint8_t offset[511][2]
static av_cold int end(AVCodecContext *avctx)
const char * name
Name of the codec implementation.
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).
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
void(* diff_bytes)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w)
av_cold int ff_huffyuv_alloc_temp(HYuvContext *s)
static double alpha(void *priv, double x, double y)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
av_cold void ff_huffyuv_common_end(HYuvContext *s)
void(* sub_hfyu_median_prediction)(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 note, this might read from src1[-1], src2[-1]
#define CODEC_FLAG_INTERLACED_ME
interlaced motion estimation
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Libavcodec external API header.
AVPixelFormat
Pixel format.
huffyuv codec for libavcodec.
int flags
A combination of AV_PKT_FLAG values.
static int put_bits_count(PutBitContext *s)
enum AVPictureType pict_type
Picture type of the frame.
#define FF_MIN_BUFFER_SIZE
minimum encoding buffer size Used to avoid some checks during header writing.
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
char * stats_out
pass1 encoding statistics output buffer
static av_cold int encode_end(AVCodecContext *avctx)
int AC3_NAME() encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define AV_LOG_INFO
Standard information.
static int sub_left_prediction(HYuvContext *s, uint8_t *dst, const uint8_t *src, int w, int left)
static int encode_422_bitstream(HYuvContext *s, int offset, int count)
main external API structure.
static void close(AVCodecParserContext *s)
BYTE int const BYTE int int int height
AVFrame * coded_frame
the picture in the bitstream
huffman tree builder and VLC generator
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int encode_bgra_bitstream(HYuvContext *s, int count, int planes)
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
#define CODEC_FLAG2_NO_OUTPUT
Skip bitstream encoding.
static int store_table(HYuvContext *s, const uint8_t *len, uint8_t *buf)
int prediction_method
prediction method (needed for huffyuv)
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 void sub_left_prediction_bgr32(HYuvContext *s, uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha)
av_cold void ff_huffyuv_common_init(AVCodecContext *avctx)
int key_frame
1 -> keyframe, 0-> not
#define av_assert0(cond)
assert() equivalent, that is always enabled.
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table)
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...