summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-05-20 18:50:38 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-05-20 18:50:38 +0200
commitb6ca7bfc7c12356e9e33eeab0ee8bf7ec865b944 (patch)
tree230202426462badca4b332c82b5f225ed3764060
parenta4c7aeaf82decc6a0d72b8d4447932363daa65a2 (diff)
avcodec/vmnc: Simplify "24bit" support
This also makes the code more robust, removing potential out of array writes. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/vmnc.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/libavcodec/vmnc.c b/libavcodec/vmnc.c
index 4bdc2ddfa0..f0033685d7 100644
--- a/libavcodec/vmnc.c
+++ b/libavcodec/vmnc.c
@@ -432,18 +432,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
c->pic->pict_type = AV_PICTURE_TYPE_I;
depth = bytestream2_get_byte(gb);
if (depth != c->bpp) {
- av_log(avctx, AV_LOG_WARNING, "Depth mismatch. "
- "Container %i bpp / Codec %i bpp\n", c->bpp, depth);
-
- if (depth != 8 && depth != 16 && depth != 32) {
- av_log(avctx, AV_LOG_ERROR,
- "Unsupported codec bitdepth %i\n", depth);
- return AVERROR_INVALIDDATA;
- }
-
- /* reset values */
- c->bpp = depth;
- c->bpp2 = c->bpp / 8;
+ av_log(avctx, AV_LOG_INFO,
+ "Depth mismatch. Container %i bpp, "
+ "Frame data: %i bpp\n",
+ c->bpp, depth);
}
bytestream2_skip(gb, 1);
c->bigendian = bytestream2_get_byte(gb);
@@ -536,7 +528,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
c->width = avctx->width;
c->height = avctx->height;
c->bpp = avctx->bits_per_coded_sample;
- c->bpp2 = c->bpp / 8;
switch (c->bpp) {
case 8:
@@ -546,8 +537,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
avctx->pix_fmt = AV_PIX_FMT_RGB555;
break;
case 24:
- /* 24 bits is not technically supported, but some clients might
- * mistakenly set it -- delay the actual check until decode_frame() */
+ c->bpp = 32;
case 32:
avctx->pix_fmt = AV_PIX_FMT_0RGB32;
break;
@@ -555,6 +545,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Unsupported bitdepth %i\n", c->bpp);
return AVERROR_INVALIDDATA;
}
+ c->bpp2 = c->bpp / 8;
c->pic = av_frame_alloc();
if (!c->pic)