summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/ffmpeg/libavcodec/sgienc.c
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/ffmpeg/libavcodec/sgienc.c')
-rw-r--r--chromium/third_party/ffmpeg/libavcodec/sgienc.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/chromium/third_party/ffmpeg/libavcodec/sgienc.c b/chromium/third_party/ffmpeg/libavcodec/sgienc.c
index 0e4f304a23c..21026afcccb 100644
--- a/chromium/third_party/ffmpeg/libavcodec/sgienc.c
+++ b/chromium/third_party/ffmpeg/libavcodec/sgienc.c
@@ -31,9 +31,12 @@
static av_cold int encode_init(AVCodecContext *avctx)
{
if (avctx->width > 65535 || avctx->height > 65535) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Unsupported resolution %dx%d.\n", avctx->width, avctx->height);
av_log(avctx, AV_LOG_ERROR, "SGI does not support resolutions above 65535x65535\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
+
avctx->coded_frame = av_frame_alloc();
if (!avctx->coded_frame)
return AVERROR(ENOMEM);
@@ -47,7 +50,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
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 int width, height, depth, dimension;
+ unsigned int bytes_per_channel, pixmax, put_be;
unsigned char *end_buf;
avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
@@ -132,14 +136,14 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
memset(buf, 0, SGI_HEADER_SIZE);
buf += 80;
- /* colormap */
+ /* colormap */
bytestream_put_be32(&buf, 0L);
/* The rest of the 512 byte header is unused. */
buf += 404;
offsettab = buf;
- if (avctx->coder_type != FF_CODER_TYPE_RAW) {
+ if (avctx->coder_type != FF_CODER_TYPE_RAW) {
/* Skip RLE offset table. */
buf += tablesize;
lengthtab = buf;
@@ -180,7 +184,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
for (y = 0; y < height; y++) {
for (x = 0; x < width * depth; x += depth)
if (bytes_per_channel == 1) {
- bytestream_put_byte(&buf, in_buf[x]);
+ bytestream_put_byte(&buf, in_buf[x]);
} else {
if (put_be) {
bytestream_put_be16(&buf, ((uint16_t *)in_buf)[x]);
@@ -195,7 +199,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
/* total length */
- pkt->size = buf - pkt->data;
+ pkt->size = buf - pkt->data;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
@@ -209,18 +213,18 @@ static av_cold int encode_close(AVCodecContext *avctx)
}
AVCodec ff_sgi_encoder = {
- .name = "sgi",
- .long_name = NULL_IF_CONFIG_SMALL("SGI image"),
- .type = AVMEDIA_TYPE_VIDEO,
- .id = AV_CODEC_ID_SGI,
- .init = encode_init,
- .encode2 = encode_frame,
- .close = encode_close,
- .pix_fmts = (const enum AVPixelFormat[]){
+ .name = "sgi",
+ .long_name = NULL_IF_CONFIG_SMALL("SGI image"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_SGI,
+ .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,
AV_PIX_FMT_RGBA64LE, AV_PIX_FMT_RGBA64BE,
- AV_PIX_FMT_GRAY16LE, AV_PIX_FMT_GRAY16BE,
- AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE
+ AV_PIX_FMT_GRAY16LE, AV_PIX_FMT_GRAY16BE, AV_PIX_FMT_GRAY8,
+ AV_PIX_FMT_NONE
},
};