25 #include "libavutil/imgutils.h"
31 #define MAX_RLE_BULK 127
33 #define MAX_RLE_REPEAT 128
35 #define MAX_RLE_SKIP 254
126 unsigned int skipcount;
133 int total_repeat_cost;
136 int lowest_bulk_cost;
137 int lowest_bulk_cost_index;
138 int sec_lowest_bulk_cost;
139 int sec_lowest_bulk_cost_index;
141 uint8_t *this_line = p->
data[0] + line*p-> linesize[0] +
150 lowest_bulk_cost = INT_MAX / 2;
151 lowest_bulk_cost_index =
width;
152 sec_lowest_bulk_cost = INT_MAX / 2;
153 sec_lowest_bulk_cost_index =
width;
157 for (i = width - 1; i >= 0; i--) {
164 lowest_bulk_cost = sec_lowest_bulk_cost;
165 lowest_bulk_cost_index = sec_lowest_bulk_cost_index;
167 sec_lowest_bulk_cost = INT_MAX / 2;
168 sec_lowest_bulk_cost_index =
width;
175 sec_lowest_bulk_cost++;
180 prev_bulk_cost = s->
length_table[i + 1] + base_bulk_cost;
181 if (prev_bulk_cost <= sec_lowest_bulk_cost) {
184 if (prev_bulk_cost <= lowest_bulk_cost) {
189 sec_lowest_bulk_cost = INT_MAX / 2;
191 lowest_bulk_cost = prev_bulk_cost;
192 lowest_bulk_cost_index = i + 1;
195 sec_lowest_bulk_cost = prev_bulk_cost;
196 sec_lowest_bulk_cost_index = i + 1;
223 if (repeatcount > 1 && (skipcount == 0 || total_repeat_cost < total_skip_cost)) {
228 else if (skipcount > 0) {
259 bytestream_put_byte(buf, s->
skip_table[0] + 1);
262 else bytestream_put_byte(buf, 1);
267 bytestream_put_byte(buf, rlecode);
270 bytestream_put_byte(buf, s->
skip_table[i] + 1);
273 else if (rlecode > 0) {
281 bytestream_put_byte(buf, *(this_line + i*s->
pixel_size + j) ^ 0xff);
293 bytestream_put_byte(buf, *(this_line + i*s->
pixel_size + j) ^ 0xff);
300 bytestream_put_byte(buf, -1);
313 for (start_line = 0; start_line < s->
avctx->
height; start_line++)
319 for (end_line=s->
avctx->
height; end_line > start_line; end_line--)
326 bytestream_put_be32(&buf, 0);
329 bytestream_put_be16(&buf, 0);
331 bytestream_put_be16(&buf, 8);
332 bytestream_put_be16(&buf, start_line);
333 bytestream_put_be16(&buf, 0);
334 bytestream_put_be16(&buf, end_line - start_line);
335 bytestream_put_be16(&buf, 0);
337 for (i = start_line; i < end_line; i++)
340 bytestream_put_byte(&buf, 0);
341 AV_WB32(orig_buf, buf - orig_buf);
342 return buf - orig_buf;
346 const AVFrame *pict,
int *got_packet)
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and/or allocate data.
int * length_table
This array will contain the length of the best rle encoding of the line starting at ith pixel...
This structure describes decoded (raw) audio or video data.
int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
static av_cold int init(AVCodecContext *avctx)
packed RGB 8:8:8, 24bpp, RGBRGB...
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.
static av_cold int qtrle_encode_end(AVCodecContext *avctx)
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
void av_picture_copy(AVPicture *dst, const AVPicture *src, enum AVPixelFormat pix_fmt, int width, int height)
Copy image src to dst.
const char * name
Name of the codec implementation.
uint8_t * skip_table
Will contain at ith position the number of consecutive pixels equal to the previous frame starting fr...
void avpicture_free(AVPicture *picture)
Free a picture previously allocated by avpicture_alloc().
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointers to the image data planes
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define MAX_RLE_BULK
Maximum RLE code for bulk copy.
static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
#define MAX_RLE_SKIP
Maximum RLE code for skip.
Libavcodec external API header.
AVPixelFormat
Pixel format.
int flags
A combination of AV_PKT_FLAG values.
static av_cold int qtrle_encode_init(AVCodecContext *avctx)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
#define MAX_RLE_REPEAT
Maximum RLE code for repeat.
int AC3_NAME() encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
unsigned int max_buf_size
main external API structure.
static void close(AVCodecParserContext *s)
int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height)
Allocate memory for the pixels of a picture and setup the AVPicture fields for it.
AVFrame * coded_frame
the picture in the bitstream
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static void qtrle_encode_line(QtrleEncContext *s, const AVFrame *p, int line, uint8_t **buf)
Compute the best RLE sequence for a line.
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
common internal api header.
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
signed char * rlecode_table
This array will contain at ith position the value of the best RLE code if the line started at pixel i...
int key_frame
1 -> keyframe, 0-> not
int frame_number
Frame counter, set by libavcodec.
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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 ...