X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmsrle.c;h=4b9dc0ce5bae4078d89e92a291b3674db9879889;hb=99fac0806b0d20790b57b4f6c96676139438e2f6;hp=f7819cb951f507fb81a16c6511fdef3344a3a585;hpb=aa39a62205739a171787744784a20482b13ccbf7;p=ffmpeg diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c index f7819cb951f..4b9dc0ce5ba 100644 --- a/libavcodec/msrle.c +++ b/libavcodec/msrle.c @@ -2,19 +2,21 @@ * Micrsoft RLE Video Decoder * Copyright (C) 2003 the ffmpeg project * - * This library is free software; you can redistribute it and/or + * This file is part of FFmpeg. + * + * 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 of the License, or (at your option) any later version. + * version 2.1 of the License, or (at your option) any later version. * - * This library 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 this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /** @@ -34,14 +36,12 @@ #include #include -#include "common.h" #include "avcodec.h" #include "dsputil.h" typedef struct MsrleContext { AVCodecContext *avctx; AVFrame frame; - AVFrame prev_frame; unsigned char *buf; int size; @@ -111,8 +111,8 @@ static void msrle_decode_pal4(MsrleContext *s) FETCH_NEXT_STREAM_BYTE(); s->frame.data[0][row_ptr + pixel_ptr] = stream_byte >> 4; pixel_ptr++; - if (i + 1 == rle_code && odd_pixel) - break; + if (i + 1 == rle_code && odd_pixel) + break; if (pixel_ptr >= s->avctx->width) break; s->frame.data[0][row_ptr + pixel_ptr] = stream_byte & 0x0F; @@ -238,13 +238,12 @@ static void msrle_decode_pal8(MsrleContext *s) static int msrle_decode_init(AVCodecContext *avctx) { - MsrleContext *s = (MsrleContext *)avctx->priv_data; + MsrleContext *s = avctx->priv_data; s->avctx = avctx; avctx->pix_fmt = PIX_FMT_PAL8; - avctx->has_b_frames = 0; - s->frame.data[0] = s->prev_frame.data[0] = NULL; + s->frame.data[0] = NULL; return 0; } @@ -253,36 +252,18 @@ static int msrle_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { - MsrleContext *s = (MsrleContext *)avctx->priv_data; - - /* no supplementary picture */ - if (buf_size == 0) - return 0; + MsrleContext *s = avctx->priv_data; s->buf = buf; s->size = buf_size; s->frame.reference = 1; - s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE; - if (avctx->cr_available) - s->frame.buffer_hints |= FF_BUFFER_HINTS_REUSABLE; - else - s->frame.buffer_hints |= FF_BUFFER_HINTS_READABLE; - if (avctx->get_buffer(avctx, &s->frame)) { - av_log(avctx, AV_LOG_ERROR, " MS RLE: get_buffer() failed\n"); + s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; + if (avctx->reget_buffer(avctx, &s->frame)) { + av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } - if (s->prev_frame.data[0] && (s->frame.linesize[0] != s->prev_frame.linesize[0])) - av_log(avctx, AV_LOG_ERROR, " MS RLE: Buffer linesize changed: current %u, previous %u.\n" - " Expect wrong image and/or crash!\n", - s->frame.linesize[0], s->prev_frame.linesize[0]); - - /* grossly inefficient, but...oh well */ - if (s->prev_frame.data[0] != NULL) - memcpy(s->frame.data[0], s->prev_frame.data[0], - s->frame.linesize[0] * s->avctx->height); - switch (avctx->bits_per_sample) { case 8: msrle_decode_pal8(s); @@ -295,13 +276,6 @@ static int msrle_decode_frame(AVCodecContext *avctx, avctx->bits_per_sample); } - if (s->prev_frame.data[0]) - avctx->release_buffer(avctx, &s->prev_frame); - - /* shuffle frames */ - if (!avctx->cr_available) - s->prev_frame = s->frame; - *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; @@ -311,11 +285,11 @@ static int msrle_decode_frame(AVCodecContext *avctx, static int msrle_decode_end(AVCodecContext *avctx) { - MsrleContext *s = (MsrleContext *)avctx->priv_data; + MsrleContext *s = avctx->priv_data; /* release the last frame */ - if (s->prev_frame.data[0]) - avctx->release_buffer(avctx, &s->prev_frame); + if (s->frame.data[0]) + avctx->release_buffer(avctx, &s->frame); return 0; } @@ -329,5 +303,5 @@ AVCodec msrle_decoder = { NULL, msrle_decode_end, msrle_decode_frame, - CODEC_CAP_DR1 | CODEC_CAP_CR, + CODEC_CAP_DR1, };