28 #define SGI_SINGLE_CHAN 2
29 #define SGI_MULTI_CHAN 3
33 if (avctx->
width > 65535 || avctx->
height > 65535) {
35 "Unsupported resolution %dx%d.\n", avctx->
width, avctx->
height);
47 const AVFrame *frame,
int *got_packet)
49 const AVFrame *
const p = frame;
50 uint8_t *offsettab, *lengthtab, *in_buf, *encode_buf, *buf;
51 int x, y, z, length, tablesize, ret;
53 unsigned int bytes_per_channel, pixmax, put_be;
54 unsigned char *end_buf;
61 bytes_per_channel = 1;
82 bytes_per_channel = 2;
91 bytes_per_channel = 2;
100 bytes_per_channel = 2;
109 tablesize = depth * height * 4;
112 length += depth * height *
width;
114 length += tablesize * 2 + depth * height * (2 * width + 1);
126 bytestream_put_byte(&buf, bytes_per_channel);
127 bytestream_put_be16(&buf, dimension);
128 bytestream_put_be16(&buf, width);
129 bytestream_put_be16(&buf, height);
130 bytestream_put_be16(&buf, depth);
132 bytestream_put_be32(&buf, 0
L);
133 bytestream_put_be32(&buf, pixmax);
134 bytestream_put_be32(&buf, 0
L);
141 bytestream_put_be32(&buf, 0
L);
159 for (z = 0; z < depth; z++) {
160 in_buf = p->
data[0] + p->
linesize[0] * (height - 1) + z;
162 for (y = 0; y <
height; y++) {
163 bytestream_put_be32(&offsettab, buf - pkt->
data);
165 for (x = 0; x <
width; x++)
166 encode_buf[x] = in_buf[depth * x];
168 if ((length =
ff_rle_encode(buf, end_buf - buf - 1, encode_buf, 1, width, 0, 0, 0x80, 0)) < 1) {
174 bytestream_put_byte(&buf, 0);
175 bytestream_put_be32(&lengthtab, length + 1);
182 for (z = 0; z < depth; z++) {
183 in_buf = p->
data[0] + p->
linesize[0] * (height - 1) + z * bytes_per_channel;
185 for (y = 0; y <
height; y++) {
186 for (x = 0; x < width * depth; x += depth)
187 if (bytes_per_channel == 1)
188 bytestream_put_byte(&buf, in_buf[x]);
191 bytestream_put_be16(&buf, ((uint16_t *)in_buf)[x]);
193 bytestream_put_le16(&buf, ((uint16_t *)in_buf)[x]);
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
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.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
const char * name
Name of the codec implementation.
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
#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(). ...
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. ...
Libavcodec external API header.
AVPixelFormat
Pixel format.
int flags
A combination of AV_PKT_FLAG values.
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
static av_cold int encode_init(AVCodecContext *avctx)
int ff_alloc_packet(AVPacket *avpkt, int size)
Check AVPacket size and/or allocate data.
main external API structure.
static av_cold int encode_close(AVCodecContext *avctx)
AVFrame * coded_frame
the picture in the bitstream
#define FF_CODER_TYPE_RAW
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
#define SGI_MAGIC
SGI image file signature.
common internal api header.
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Y , 16bpp, little-endian.
int key_frame
1 -> keyframe, 0-> not
int ff_rle_encode(uint8_t *outbuf, int out_size, const uint8_t *ptr, int bpp, int w, int add_rep, int xor_rep, int add_raw, int xor_raw)
RLE compress the row, with maximum size of out_size.
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.