56 bytestream_put_byte(
data, 255);
74 bytestream_put_byte(
data, 0);
75 bytestream_put_byte(
data, 254);
84 }
else if (
len == 2) {
88 bytestream_put_byte(
data, 0);
92 bytestream_put_byte(
data, 0);
102 while (
delta >= 255) {
103 bytestream_put_byte(
data, 0);
104 bytestream_put_byte(
data, 2);
105 bytestream_put_byte(
data, 255);
106 bytestream_put_byte(
data, 0);
110 bytestream_put_byte(
data, 0);
111 bytestream_put_byte(
data, 2);
113 bytestream_put_byte(
data, 0);
125 while (yskip >= 255) {
126 bytestream_put_byte(
data, 0);
127 bytestream_put_byte(
data, 2);
128 bytestream_put_byte(
data, 0);
129 bytestream_put_byte(
data, 255);
133 bytestream_put_byte(
data, 0);
134 bytestream_put_byte(
data, 2);
135 bytestream_put_byte(
data, 0);
136 bytestream_put_byte(
data, yskip);
138 bytestream_put_be16(
data, 0x0000);
143 const uint8_t *
line,
int length)
145 int run = 0, last = -1, absstart = 0;
148 for (
int x = 0; x < length; x++) {
149 if (last ==
line[x]) {
169 const AVFrame *pict,
int keyframe,
int *got_keyframe)
190 for (
int y = avctx->
height-1; y >= 0; y--) {
193 bytestream_put_be16(&
data, 0x0000);
198 for (
int y = avctx->
height-1; y >= 0; y--) {
200 const uint8_t *prev = &
s->last_frame->data[0][y*
s->last_frame->linesize[0]];
202 int delta = 0, linestart = 0, encoded = 0;
203 for (
int x = 0; x < avctx->
width; x++) {
204 if (
line[x] == prev[x]) {
207 int len = x - linestart - 4;
236 bytestream_put_be16(&
data, 0x0000);
244 bytestream_put_be16(&
data, 0x0001);
250 const AVFrame *pict,
int *got_packet)
253 int ret, got_keyframe;
267 if ((ret =
encode(avctx,
pkt, pict,
s->curframe == 0, &got_keyframe)))
const FFCodec ff_msrle_encoder
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
#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...
int(* init)(AVBSFContext *ctx)
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
#define FF_INPUT_BUFFER_MIN_SIZE
Used by some encoders as upper bound for the length of headers.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int av_frame_replace(AVFrame *dst, const AVFrame *src)
Ensure the destination frame refers to the same data described by the source frame,...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Macro definitions for various function/variable attributes.
static av_cold int msrle_encode_close(AVCodecContext *avctx)
static void write_absolute(AVCodecContext *avctx, uint8_t **data, const uint8_t *line, int len)
static void write_delta(AVCodecContext *avctx, uint8_t **data, int delta)
static void encode_line(AVCodecContext *avctx, uint8_t **data, const uint8_t *line, int length)
static int encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int keyframe, int *got_keyframe)
static void write_yskip(AVCodecContext *avctx, uint8_t **data, int yskip)
static int msrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
static av_cold int msrle_encode_init(AVCodecContext *avctx)
static void write_run(AVCodecContext *avctx, uint8_t **data, int len, int value)
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
main external API structure.
int width
picture width / height.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
This structure stores compressed data.