diff options
Diffstat (limited to 'libavcodec/sunrastenc.c')
-rw-r--r-- | libavcodec/sunrastenc.c | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/libavcodec/sunrastenc.c b/libavcodec/sunrastenc.c index ddf624eee2..d83a42dd0f 100644 --- a/libavcodec/sunrastenc.c +++ b/libavcodec/sunrastenc.c @@ -2,20 +2,20 @@ * Sun Rasterfile (.sun/.ras/im{1,8,24}/.sunras) image encoder * Copyright (c) 2012 Aneesh Dogra (lionaneesh) <lionaneesh@gmail.com> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -55,7 +55,7 @@ static void sunrast_image_write_image(AVCodecContext *avctx, { SUNRASTContext *s = avctx->priv_data; const uint8_t *ptr; - int len, alen, x; + int len, alen, x, y; if (s->maplength) { // palettized PutByteContext pb_r, pb_g; @@ -82,33 +82,29 @@ static void sunrast_image_write_image(AVCodecContext *avctx, if (s->type == RT_BYTE_ENCODED) { uint8_t value, value2; int run; - const uint8_t *start = linesize < 0 ? pixels + (avctx->height - 1) * linesize - : pixels; - const uint8_t *end = linesize < 0 ? pixels - linesize - : pixels + avctx->height * linesize; ptr = pixels; -#define GET_VALUE ptr >= end || ptr < start ? 0 : x >= len ? ptr[len-1] : ptr[x] +#define GET_VALUE y >= avctx->height ? 0 : x >= len ? ptr[len-1] : ptr[x] - x = 0; + x = 0, y = 0; value2 = GET_VALUE; - while (ptr < end && ptr >= start) { + while (y < avctx->height) { run = 1; value = value2; x++; if (x >= alen) { x = 0; - ptr += linesize; + ptr += linesize, y++; } value2 = GET_VALUE; - while (value2 == value && run < 256 && ptr < end && ptr >= start) { + while (value2 == value && run < 256 && y < avctx->height) { x++; run++; if (x >= alen) { x = 0; - ptr += linesize; + ptr += linesize, y++; } value2 = GET_VALUE; } @@ -127,7 +123,6 @@ static void sunrast_image_write_image(AVCodecContext *avctx, // update data length for header s->length = bytestream2_tell_p(&s->p) - 32 - s->maplength; } else { - int y; for (y = 0; y < avctx->height; y++) { bytestream2_put_buffer(&s->p, ptr, len); if (len < alen) @@ -153,12 +148,6 @@ static av_cold int sunrast_encode_init(AVCodecContext *avctx) return AVERROR(EINVAL); } -#if FF_API_CODED_FRAME -FF_DISABLE_DEPRECATION_WARNINGS - avctx->coded_frame->key_frame = 1; - avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; -FF_ENABLE_DEPRECATION_WARNINGS -#endif s->maptype = RMT_NONE; s->maplength = 0; @@ -192,7 +181,7 @@ static int sunrast_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, SUNRASTContext *s = avctx->priv_data; int ret; - if ((ret = ff_alloc_packet(avpkt, s->size)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, s->size, 0)) < 0) return ret; bytestream2_init_writer(&s->p, avpkt->data, avpkt->size); |