summaryrefslogtreecommitdiff
path: root/ffmpeg/libavcodec/sgienc.c
diff options
context:
space:
mode:
Diffstat (limited to 'ffmpeg/libavcodec/sgienc.c')
-rw-r--r--ffmpeg/libavcodec/sgienc.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/ffmpeg/libavcodec/sgienc.c b/ffmpeg/libavcodec/sgienc.c
index d03ef52..0e4f304 100644
--- a/ffmpeg/libavcodec/sgienc.c
+++ b/ffmpeg/libavcodec/sgienc.c
@@ -28,21 +28,15 @@
#define SGI_SINGLE_CHAN 2
#define SGI_MULTI_CHAN 3
-typedef struct SgiContext {
- AVFrame picture;
-} SgiContext;
-
static av_cold int encode_init(AVCodecContext *avctx)
{
- SgiContext *s = avctx->priv_data;
-
if (avctx->width > 65535 || avctx->height > 65535) {
av_log(avctx, AV_LOG_ERROR, "SGI does not support resolutions above 65535x65535\n");
return -1;
}
-
- avcodec_get_frame_defaults(&s->picture);
- avctx->coded_frame = &s->picture;
+ avctx->coded_frame = av_frame_alloc();
+ if (!avctx->coded_frame)
+ return AVERROR(ENOMEM);
return 0;
}
@@ -50,16 +44,14 @@ static av_cold int encode_init(AVCodecContext *avctx)
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet)
{
- SgiContext *s = avctx->priv_data;
- AVFrame * const p = &s->picture;
+ const AVFrame * const p = frame;
uint8_t *offsettab, *lengthtab, *in_buf, *encode_buf, *buf;
int x, y, z, length, tablesize, ret;
unsigned int width, height, depth, dimension, bytes_per_channel, pixmax, put_be;
unsigned char *end_buf;
- *p = *frame;
- p->pict_type = AV_PICTURE_TYPE_I;
- p->key_frame = 1;
+ avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ avctx->coded_frame->key_frame = 1;
width = avctx->width;
height = avctx->height;
@@ -210,13 +202,20 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
return 0;
}
+static av_cold int encode_close(AVCodecContext *avctx)
+{
+ av_frame_free(&avctx->coded_frame);
+ return 0;
+}
+
AVCodec ff_sgi_encoder = {
.name = "sgi",
+ .long_name = NULL_IF_CONFIG_SMALL("SGI image"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_SGI,
- .priv_data_size = sizeof(SgiContext),
.init = encode_init,
.encode2 = encode_frame,
+ .close = encode_close,
.pix_fmts = (const enum AVPixelFormat[]){
AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA,
AV_PIX_FMT_RGB48LE, AV_PIX_FMT_RGB48BE,
@@ -224,5 +223,4 @@ AVCodec ff_sgi_encoder = {
AV_PIX_FMT_GRAY16LE, AV_PIX_FMT_GRAY16BE,
AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE
},
- .long_name = NULL_IF_CONFIG_SMALL("SGI image"),
};