31 #define MAX_RLE_BULK 127 33 #define MAX_RLE_REPEAT 128 35 #define MAX_RLE_SKIP 254 89 if (avctx->
width % 4) {
143 unsigned int skipcount;
150 int total_repeat_cost;
153 int lowest_bulk_cost;
154 int lowest_bulk_cost_index;
155 int sec_lowest_bulk_cost;
156 int sec_lowest_bulk_cost_index;
158 uint8_t *this_line = p->
data[0] + line*p-> linesize[0] +
167 lowest_bulk_cost = INT_MAX / 2;
168 lowest_bulk_cost_index =
width;
169 sec_lowest_bulk_cost = INT_MAX / 2;
170 sec_lowest_bulk_cost_index =
width;
174 for (i = width - 1; i >= 0; i--) {
181 lowest_bulk_cost = sec_lowest_bulk_cost;
182 lowest_bulk_cost_index = sec_lowest_bulk_cost_index;
184 sec_lowest_bulk_cost = INT_MAX / 2;
185 sec_lowest_bulk_cost_index =
width;
192 sec_lowest_bulk_cost++;
197 prev_bulk_cost = s->
length_table[i + 1] + base_bulk_cost;
198 if (prev_bulk_cost <= sec_lowest_bulk_cost) {
201 if (prev_bulk_cost <= lowest_bulk_cost) {
206 sec_lowest_bulk_cost = INT_MAX / 2;
208 lowest_bulk_cost = prev_bulk_cost;
209 lowest_bulk_cost_index = i + 1;
212 sec_lowest_bulk_cost = prev_bulk_cost;
213 sec_lowest_bulk_cost_index = i + 1;
240 if (repeatcount > 1 && (skipcount == 0 || total_repeat_cost < total_skip_cost)) {
245 else if (skipcount > 0) {
277 bytestream_put_byte(buf, s->
skip_table[0] + 1);
280 else bytestream_put_byte(buf, 1);
285 bytestream_put_byte(buf, rlecode);
288 bytestream_put_byte(buf, s->
skip_table[i] + 1);
291 else if (rlecode > 0) {
299 bytestream_put_byte(buf, *(this_line + i*s->
pixel_size + j) ^ 0xff);
311 bytestream_put_byte(buf, *(this_line + i*s->
pixel_size + j) ^ 0xff);
318 bytestream_put_byte(buf, -1);
331 for (start_line = 0; start_line < s->
avctx->
height; start_line++)
337 for (end_line=s->
avctx->
height; end_line > start_line; end_line--)
344 bytestream_put_be32(&buf, 0);
347 bytestream_put_be16(&buf, 0);
349 bytestream_put_be16(&buf, 8);
350 bytestream_put_be16(&buf, start_line);
351 bytestream_put_be16(&buf, 0);
352 bytestream_put_be16(&buf, end_line - start_line);
353 bytestream_put_be16(&buf, 0);
355 for (i = start_line; i < end_line; i++)
358 bytestream_put_byte(&buf, 0);
359 AV_WB32(orig_buf, buf - orig_buf);
360 return buf - orig_buf;
364 const AVFrame *pict,
int *got_packet)
390 #if FF_API_CODED_FRAME #define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
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.
ptrdiff_t const GLvoid * data
packed RGB 8:8:8, 24bpp, RGBRGB...
static av_cold int init(AVCodecContext *avctx)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static int encode_frame(QtrleEncContext *s, const AVFrame *p, uint8_t *buf)
Encode frame including header.
static av_cold int qtrle_encode_end(AVCodecContext *avctx)
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int key_frame
Encoded frame is a key frame.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
uint8_t * skip_table
Will contain at ith position the number of consecutive pixels equal to the previous frame starting fr...
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.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#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)
const char * name
Name of the codec implementation.
#define MAX_RLE_SKIP
Maximum RLE code for skip.
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
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.
unsigned int max_buf_size
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static enum AVPixelFormat pix_fmts[]
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
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...
#define FF_ENABLE_DEPRECATION_WARNINGS
int key_frame
1 -> keyframe, 0-> not
int frame_number
Frame counter, set by libavcodec.
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
AVPixelFormat
Pixel format.
This structure stores compressed data.
void * av_mallocz_array(size_t nmemb, size_t size)