aboutsummaryrefslogtreecommitdiff
path: root/lib/ffmpeg/libavcodec/msrle.c
diff options
context:
space:
mode:
authorFlyingRat <flyingrat@outlook.com>2013-04-07 16:36:04 +0200
committerFlyingRat <flyingrat@outlook.com>2013-04-07 16:36:04 +0200
commit0e63a815aa6af63a21848e04b683d3f506dd41b1 (patch)
tree002f61d8a5b1d294d99fd4ba5b6982d76a612f0c /lib/ffmpeg/libavcodec/msrle.c
parent71862137c5337fc678681a23bfbc65f4db7a7b2f (diff)
[FFmpeg] version bump to n1.2 (rev e820e3a) - lib/ffmpeg
This commit now contains the original patches sub directory: patches - Org dir that contains applied xbmc custom patches. patches/README-patches - New README file with info about xbmc patches. patches/obsolete-patches - New dir with obsolete xbmc patches.
Diffstat (limited to 'lib/ffmpeg/libavcodec/msrle.c')
-rw-r--r--lib/ffmpeg/libavcodec/msrle.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/lib/ffmpeg/libavcodec/msrle.c b/lib/ffmpeg/libavcodec/msrle.c
index 2f3f876b15..7187d1a5e1 100644
--- a/lib/ffmpeg/libavcodec/msrle.c
+++ b/lib/ffmpeg/libavcodec/msrle.c
@@ -33,13 +33,13 @@
#include <string.h>
#include "avcodec.h"
-#include "dsputil.h"
#include "msrledec.h"
typedef struct MsrleContext {
AVCodecContext *avctx;
AVFrame frame;
+ GetByteContext gb;
const unsigned char *buf;
int size;
@@ -49,48 +49,54 @@ typedef struct MsrleContext {
static av_cold int msrle_decode_init(AVCodecContext *avctx)
{
MsrleContext *s = avctx->priv_data;
+ int i;
s->avctx = avctx;
switch (avctx->bits_per_coded_sample) {
case 1:
- avctx->pix_fmt = PIX_FMT_MONOWHITE;
+ avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
break;
case 4:
case 8:
- avctx->pix_fmt = PIX_FMT_PAL8;
+ avctx->pix_fmt = AV_PIX_FMT_PAL8;
break;
case 24:
- avctx->pix_fmt = PIX_FMT_BGR24;
+ avctx->pix_fmt = AV_PIX_FMT_BGR24;
break;
default:
av_log(avctx, AV_LOG_ERROR, "unsupported bits per sample\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
avcodec_get_frame_defaults(&s->frame);
s->frame.data[0] = NULL;
+ if (avctx->extradata_size >= 4)
+ for (i = 0; i < FFMIN(avctx->extradata_size, AVPALETTE_SIZE)/4; i++)
+ s->pal[i] = 0xFFU<<24 | AV_RL32(avctx->extradata+4*i);
+
return 0;
}
static int msrle_decode_frame(AVCodecContext *avctx,
- void *data, int *data_size,
+ void *data, int *got_frame,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
MsrleContext *s = avctx->priv_data;
int istride = FFALIGN(avctx->width*avctx->bits_per_coded_sample, 32) / 8;
+ int ret;
s->buf = buf;
s->size = buf_size;
s->frame.reference = 3;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
- if (avctx->reget_buffer(avctx, &s->frame)) {
+ if ((ret = avctx->reget_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
- return -1;
+ return ret;
}
if (avctx->bits_per_coded_sample > 1 && avctx->bits_per_coded_sample <= 8) {
@@ -100,7 +106,6 @@ static int msrle_decode_frame(AVCodecContext *avctx,
s->frame.palette_has_changed = 1;
memcpy(s->pal, pal, AVPALETTE_SIZE);
}
-
/* make the palette available */
memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE);
}
@@ -127,10 +132,11 @@ static int msrle_decode_frame(AVCodecContext *avctx,
ptr += s->frame.linesize[0];
}
} else {
- ff_msrle_decode(avctx, (AVPicture*)&s->frame, avctx->bits_per_coded_sample, buf, buf_size);
+ bytestream2_init(&s->gb, buf, buf_size);
+ ff_msrle_decode(avctx, (AVPicture*)&s->frame, avctx->bits_per_coded_sample, &s->gb);
}
- *data_size = sizeof(AVFrame);
+ *got_frame = 1;
*(AVFrame*)data = s->frame;
/* report that the buffer was completely consumed */
@@ -151,11 +157,11 @@ static av_cold int msrle_decode_end(AVCodecContext *avctx)
AVCodec ff_msrle_decoder = {
.name = "msrle",
.type = AVMEDIA_TYPE_VIDEO,
- .id = CODEC_ID_MSRLE,
+ .id = AV_CODEC_ID_MSRLE,
.priv_data_size = sizeof(MsrleContext),
.init = msrle_decode_init,
.close = msrle_decode_end,
.decode = msrle_decode_frame,
.capabilities = CODEC_CAP_DR1,
- .long_name= NULL_IF_CONFIG_SMALL("Microsoft RLE"),
+ .long_name = NULL_IF_CONFIG_SMALL("Microsoft RLE"),
};