|
|
@ -31,7 +31,8 @@ typedef struct SgiContext { |
|
|
|
AVFrame picture; |
|
|
|
AVFrame picture; |
|
|
|
} SgiContext; |
|
|
|
} SgiContext; |
|
|
|
|
|
|
|
|
|
|
|
static av_cold int encode_init(AVCodecContext *avctx){ |
|
|
|
static av_cold int encode_init(AVCodecContext *avctx) |
|
|
|
|
|
|
|
{ |
|
|
|
SgiContext *s = avctx->priv_data; |
|
|
|
SgiContext *s = avctx->priv_data; |
|
|
|
|
|
|
|
|
|
|
|
avcodec_get_frame_defaults(&s->picture); |
|
|
|
avcodec_get_frame_defaults(&s->picture); |
|
|
@ -41,7 +42,8 @@ static av_cold int encode_init(AVCodecContext *avctx){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, |
|
|
|
static int encode_frame(AVCodecContext *avctx, unsigned char *buf, |
|
|
|
int buf_size, void *data) { |
|
|
|
int buf_size, void *data) |
|
|
|
|
|
|
|
{ |
|
|
|
SgiContext *s = avctx->priv_data; |
|
|
|
SgiContext *s = avctx->priv_data; |
|
|
|
AVFrame * const p = &s->picture; |
|
|
|
AVFrame * const p = &s->picture; |
|
|
|
uint8_t *offsettab, *lengthtab, *in_buf, *encode_buf; |
|
|
|
uint8_t *offsettab, *lengthtab, *in_buf, *encode_buf; |
|
|
@ -127,7 +129,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, |
|
|
|
for (x = 0; x < width; x++) |
|
|
|
for (x = 0; x < width; x++) |
|
|
|
encode_buf[x] = in_buf[depth * x]; |
|
|
|
encode_buf[x] = in_buf[depth * x]; |
|
|
|
|
|
|
|
|
|
|
|
if((length = ff_rle_encode(buf, end_buf - buf - 1, encode_buf, 1, width, 0, 0, 0x80, 0)) < 1) { |
|
|
|
if ((length = ff_rle_encode(buf, end_buf - buf - 1, encode_buf, 1, width, 0, 0, 0x80, 0)) < 1) { |
|
|
|
av_free(encode_buf); |
|
|
|
av_free(encode_buf); |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
@ -168,4 +170,3 @@ AVCodec sgi_encoder = { |
|
|
|
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGBA, PIX_FMT_GRAY8, PIX_FMT_NONE}, |
|
|
|
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGBA, PIX_FMT_GRAY8, PIX_FMT_NONE}, |
|
|
|
.long_name= NULL_IF_CONFIG_SMALL("SGI image"), |
|
|
|
.long_name= NULL_IF_CONFIG_SMALL("SGI image"), |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|