30 #define SGI_SINGLE_CHAN 2 31 #define SGI_MULTI_CHAN 3 41 if (avctx->
width > 65535 || avctx->
height > 65535) {
43 "Unsupported resolution %dx%d.\n", avctx->
width, avctx->
height);
57 bytestream2_put = bytestream2_put_byte;
59 bytestream2_put = bytestream2_put_be16;
61 for (x = 0; x < w; x += count) {
69 bytestream2_put(pbc, count);
70 bytestream2_put(pbc, val);
78 bytestream2_put(pbc, count + 0x80);
79 for (i = 0; i < count; i++) {
80 val = bpp == 1 ? src[i] :
AV_RB16(src + i * bpp);
81 bytestream2_put(pbc, val);
92 const AVFrame *frame,
int *got_packet)
95 const AVFrame *
const p = frame;
98 int x, y, z, length, tablesize, ret, i;
100 unsigned int bytes_per_channel, pixmax, put_be;
102 #if FF_API_CODED_FRAME 109 #if FF_API_CODER_TYPE 116 width = avctx->
width;
118 bytes_per_channel = 1;
138 bytes_per_channel = 2;
146 bytes_per_channel = 2;
154 bytes_per_channel = 2;
163 tablesize = depth * height * 4;
166 length += depth * height *
width;
168 length += tablesize * 2 + depth * height * (2 * width + 1);
179 bytestream2_put_byte(&pbc, s->
rle);
180 bytestream2_put_byte(&pbc, bytes_per_channel);
181 bytestream2_put_be16(&pbc, dimension);
182 bytestream2_put_be16(&pbc, width);
183 bytestream2_put_be16(&pbc, height);
184 bytestream2_put_be16(&pbc, depth);
186 bytestream2_put_be32(&pbc, 0
L);
187 bytestream2_put_be32(&pbc, pixmax);
188 bytestream2_put_be32(&pbc, 0
L);
191 for (i = 0; i < 80; i++)
192 bytestream2_put_byte(&pbc, 0
L);
195 bytestream2_put_be32(&pbc, 0
L);
198 for (i = 0; i < 404; i++)
199 bytestream2_put_byte(&pbc, 0
L);
213 if (!(encode_buf =
av_malloc(width * bytes_per_channel)))
216 for (z = 0; z < depth; z++) {
217 in_buf = p->
data[0] + p->
linesize[0] * (height - 1) + z * bytes_per_channel;
219 for (y = 0; y <
height; y++) {
222 for (x = 0; x < width * bytes_per_channel; x += bytes_per_channel)
223 encode_buf[x] = in_buf[depth * x];
232 bytestream2_put_be32(&tablen_pcb, length);
239 for (z = 0; z < depth; z++) {
240 in_buf = p->
data[0] + p->
linesize[0] * (height - 1) + z * bytes_per_channel;
242 for (y = 0; y <
height; y++) {
243 for (x = 0; x < width * depth; x += depth)
244 if (bytes_per_channel == 1)
245 bytestream2_put_byte(&pbc, in_buf[x]);
248 bytestream2_put_be16(&pbc, ((uint16_t *)in_buf)[x]);
250 bytestream2_put_le16(&pbc, ((uint16_t *)in_buf)[x]);
265 #define OFFSET(x) offsetof(SgiContext, x) 266 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 286 .priv_class = &sgi_class,
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static const AVClass sgi_class
This structure describes decoded (raw) audio or video data.
int ff_rle_count_pixels(const uint8_t *start, int len, int bpp, int same)
Count up to 127 consecutive pixels which are either all the same or all differ from the previous and ...
packed RGB 8:8:8, 24bpp, RGBRGB...
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static const AVOption options[]
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
#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(). ...
static av_always_inline unsigned int bytestream2_get_bytes_left_p(PutByteContext *p)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const char * name
Name of the codec implementation.
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int flags
A combination of AV_PKT_FLAG values.
static av_always_inline void bytestream2_skip_p(PutByteContext *p, unsigned int size)
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static av_cold int encode_init(AVCodecContext *avctx)
int ff_alloc_packet(AVPacket *avpkt, int size)
Check AVPacket size and/or allocate data.
attribute_deprecated int coder_type
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
Describe the class of an AVClass context structure.
static enum AVPixelFormat pix_fmts[]
static int sgi_rle_encode(PutByteContext *pbc, const uint8_t *src, int w, int bpp)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define SGI_MAGIC
SGI image file signature.
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
#define FF_CODER_TYPE_RAW
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
static av_cold int init(AVCodecParserContext *s)
#define FF_ENABLE_DEPRECATION_WARNINGS
Y , 16bpp, little-endian.
int key_frame
1 -> keyframe, 0-> not
AVPixelFormat
Pixel format.
This structure stores compressed data.
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...