diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-03-28 08:23:46 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-03-28 08:26:24 +0400 |
commit | 296e63efa56f1fb454cafb5c7f54dfb80cbfbab4 (patch) | |
tree | 03b3e65e5267e1fe5870603ec59999ef3d139fee | |
parent | 6bd05ed8bb3010322a9285a29e0ea8b0934b63e9 (diff) | |
parent | 678082b409aca711f9cf991df6b0200116489322 (diff) |
Merge commit '678082b409aca711f9cf991df6b0200116489322'
* commit '678082b409aca711f9cf991df6b0200116489322':
X-Bitmap decoder
Conflicts:
Changelog
libavcodec/Makefile
libavcodec/allcodecs.c
libavcodec/version.h
libavcodec/xbmdec.c
See: a0340dfbd78df7639715056937011d2d414aaeed
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | Changelog | 1 | ||||
-rw-r--r-- | libavcodec/version.h | 2 | ||||
-rw-r--r-- | libavcodec/xbmdec.c | 39 |
3 files changed, 23 insertions, 19 deletions
@@ -9,6 +9,7 @@ version <next>: - VP7 video decoder - Alias PIX image encoder and decoder - Improvments to the BRender PIX image decoder +- Improvments to the XBM decoder version 2.2: diff --git a/libavcodec/version.h b/libavcodec/version.h index 5c12077c9c..968ff74b8f 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -30,7 +30,7 @@ #define LIBAVCODEC_VERSION_MAJOR 55 #define LIBAVCODEC_VERSION_MINOR 55 -#define LIBAVCODEC_VERSION_MICRO 102 +#define LIBAVCODEC_VERSION_MICRO 103 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavcodec/xbmdec.c b/libavcodec/xbmdec.c index 2976bec8ac..b9a46d74d0 100644 --- a/libavcodec/xbmdec.c +++ b/libavcodec/xbmdec.c @@ -20,17 +20,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/avstring.h" + #include "avcodec.h" #include "internal.h" #include "mathops.h" -#include "libavutil/avstring.h" - -static av_cold int xbm_decode_init(AVCodecContext *avctx) -{ - avctx->pix_fmt = AV_PIX_FMT_MONOWHITE; - - return 0; -} static int convert(uint8_t x) { @@ -47,33 +41,42 @@ static int xbm_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { AVFrame *p = data; + int ret, linesize, i, j; + int width = 0; + int height = 0; const uint8_t *end, *ptr = avpkt->data; uint8_t *dst; - int ret, linesize, i, j; + avctx->pix_fmt = AV_PIX_FMT_MONOWHITE; end = avpkt->data + avpkt->size; - while (!avctx->width || !avctx->height) { + while (!width || !height) { char name[256]; int number, len; ptr += strcspn(ptr, "#"); + if (ptr >= avpkt->data + avpkt->size) { + av_log(avctx, AV_LOG_ERROR, "End of file reached.\n"); + return AVERROR_INVALIDDATA; + } if (sscanf(ptr, "#define %255s %u", name, &number) != 2) { av_log(avctx, AV_LOG_ERROR, "Unexpected preprocessor directive\n"); return AVERROR_INVALIDDATA; } len = strlen(name); - if ((len > 6) && !avctx->height && !memcmp(name + len - 7, "_height", 7)) { - avctx->height = number; - } else if ((len > 5) && !avctx->width && !memcmp(name + len - 6, "_width", 6)) { - avctx->width = number; + if ((len > 6) && !height && !memcmp(name + len - 7, "_height", 7)) { + height = number; + } else if ((len > 5) && !width && !memcmp(name + len - 6, "_width", 6)) { + width = number; } else { - av_log(avctx, AV_LOG_ERROR, "Unknown define '%s'\n", name); - return AVERROR_INVALIDDATA; + av_log(avctx, AV_LOG_WARNING, "Unknown define '%s'\n", name); } ptr += strcspn(ptr, "\n\r") + 1; } + if ((ret = ff_set_dimensions(avctx, width, height)) < 0) + return ret; + if ((ret = ff_get_buffer(avctx, p, 0)) < 0) return ret; @@ -94,7 +97,8 @@ static int xbm_decode_frame(AVCodecContext *avctx, void *data, val = (val << 4) + convert(*ptr); *dst++ = ff_reverse[val]; } else { - av_log(avctx, AV_LOG_ERROR, "Unexpected data at '%.8s'\n", ptr); + av_log(avctx, AV_LOG_ERROR, + "Unexpected data at %.8s.\n", ptr); return AVERROR_INVALIDDATA; } } @@ -113,7 +117,6 @@ AVCodec ff_xbm_decoder = { .long_name = NULL_IF_CONFIG_SMALL("XBM (X BitMap) image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_XBM, - .init = xbm_decode_init, .decode = xbm_decode_frame, .capabilities = CODEC_CAP_DR1, }; |