diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-04-19 19:12:57 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-04-19 19:26:46 +0200 |
commit | e37dbfddda0380fd9ea9ba1bbae8a5ab2afc6573 (patch) | |
tree | 6d466e4b5f4f4e661031f14453a62ab2b86d0776 /libavcodec | |
parent | 928b5708f94c50e8cb0b982208a2d097b0d588c2 (diff) | |
parent | 07761294fc3f08e139e8a406ef7d5b63aaf1ecee (diff) | |
download | ffmpeg-e37dbfddda0380fd9ea9ba1bbae8a5ab2afc6573.tar.gz |
Merge commit '07761294fc3f08e139e8a406ef7d5b63aaf1ecee'
* commit '07761294fc3f08e139e8a406ef7d5b63aaf1ecee':
Silicon Graphics RLE 8-bit video decoder
Conflicts:
Changelog
doc/general.texi
libavcodec/avcodec.h
libavcodec/sgirledec.c
libavcodec/version.h
See: afa1617b937f3675f74c6351a46c45f8c24d67f2
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/avcodec.h | 1 | ||||
-rw-r--r-- | libavcodec/codec_desc.c | 14 | ||||
-rw-r--r-- | libavcodec/sgirledec.c | 65 | ||||
-rw-r--r-- | libavcodec/utils.c | 1 | ||||
-rw-r--r-- | libavcodec/version.h | 2 |
5 files changed, 47 insertions, 36 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index a7bf52a1b7..701941c988 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -292,6 +292,7 @@ enum AVCodecID { AV_CODEC_ID_EXR_DEPRECATED, AV_CODEC_ID_VP7_DEPRECATED, AV_CODEC_ID_SANM_DEPRECATED, + AV_CODEC_ID_SGIRLE_DEPRECATED, AV_CODEC_ID_BRENDER_PIX= MKBETAG('B','P','I','X'), AV_CODEC_ID_Y41P = MKBETAG('Y','4','1','P'), diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index e742b5d030..20c0160f2c 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -662,13 +662,6 @@ static const AVCodecDescriptor codec_descriptors[] = { .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, { - .id = AV_CODEC_ID_SGIRLE, - .type = AVMEDIA_TYPE_VIDEO, - .name = "sgirle", - .long_name = NULL_IF_CONFIG_SMALL("SGI RLE 8-bit"), - .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, - }, - { .id = AV_CODEC_ID_C93, .type = AVMEDIA_TYPE_VIDEO, .name = "c93", @@ -1233,6 +1226,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("LucasArts SANM/SMUSH video"), .props = AV_CODEC_PROP_LOSSY, }, + { + .id = AV_CODEC_ID_SGIRLE, + .type = AVMEDIA_TYPE_VIDEO, + .name = "sgirle", + .long_name = NULL_IF_CONFIG_SMALL("SGI RLE 8-bit"), + .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, + }, /* image codecs */ { diff --git a/libavcodec/sgirledec.c b/libavcodec/sgirledec.c index fd3cc5e78a..5e2cd3a4d3 100644 --- a/libavcodec/sgirledec.c +++ b/libavcodec/sgirledec.c @@ -1,5 +1,5 @@ /* - * SGI RLE 8-bit decoder + * Silicon Graphics RLE 8-bit video decoder * Copyright (c) 2012 Peter Ross * * This file is part of FFmpeg. @@ -21,9 +21,13 @@ /** * @file - * SGI RLE 8-bit decoder + * Silicon Graphics RLE 8-bit video decoder + * @note Data is packed in rbg323 with rle, contained in mv or mov. + * The algorithm and pixfmt are subtly different from SGI images. */ +#include "libavutil/common.h" + #include "avcodec.h" #include "internal.h" @@ -42,39 +46,44 @@ static av_cold int sgirle_decode_init(AVCodecContext *avctx) } /** - * Convert SGI RGB332 pixel into AV_PIX_FMT_BGR8 - * SGI RGB332 is packed RGB 3:3:2, 8bpp, (msb)3R 2B 3G(lsb) + * Convert SGI RBG323 pixel into AV_PIX_FMT_BGR8 + * SGI RGB data is packed as 8bpp, (msb)3R 2B 3G(lsb) */ -#define RGB332_TO_BGR8(x) (((x << 3) & 0xC0) | ((x << 3) & 0x38) | ((x >> 5) & 7)) - -static av_always_inline void memcpy_rgb332_to_bgr8(uint8_t *dst, const uint8_t *src, int size) +#define RBG323_TO_BGR8(x) (((x << 3) & 0xC0) | \ + ((x << 3) & 0x38) | \ + ((x >> 5) & 7)) +static av_always_inline +void rbg323_to_bgr8(uint8_t *dst, const uint8_t *src, int size) { int i; for (i = 0; i < size; i++) - dst[i] = RGB332_TO_BGR8(src[i]); + dst[i] = RBG323_TO_BGR8(src[i]); } /** * @param[out] dst Destination buffer - * @param[in] src Source buffer + * @param[in] src Source buffer * @param src_size Source buffer size (bytes) - * @param width Width of destination buffer (pixels) - * @param height Height of destination buffer (pixels) + * @param width Width of destination buffer (pixels) + * @param height Height of destination buffer (pixels) * @param linesize Line size of destination buffer (bytes) + * * @return <0 on error */ -static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *src, int src_size, int width, int height, int linesize) +static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, + const uint8_t *src, int src_size, + int width, int height, ptrdiff_t linesize) { const uint8_t *src_end = src + src_size; int x = 0, y = 0; -#define INC_XY(n) \ - x += n; \ - if (x >= width) { \ - y++; \ - if (y >= height) \ - return 0; \ - x = 0; \ +#define INC_XY(n) \ + x += n; \ + if (x >= width) { \ + y++; \ + if (y >= height) \ + return 0; \ + x = 0; \ } while (src_end - src >= 2) { @@ -84,9 +93,9 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *sr int length = FFMIN(v, width - x); if (length <= 0) break; - memset(dst + y*linesize + x, RGB332_TO_BGR8(*src), length); + memset(dst + y * linesize + x, RBG323_TO_BGR8(*src), length); INC_XY(length); - v -= length; + v -= length; } while (v > 0); src++; } else if (v >= 0xC1) { @@ -95,7 +104,7 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *sr int length = FFMIN3(v, width - x, src_end - src); if (src_end - src < length || length <= 0) break; - memcpy_rgb332_to_bgr8(dst + y*linesize + x, src, length); + rbg323_to_bgr8(dst + y * linesize + x, src, length); INC_XY(length); src += length; v -= length; @@ -108,9 +117,8 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *sr return 0; } -static int sgirle_decode_frame(AVCodecContext *avctx, - void *data, int *got_frame, - AVPacket *avpkt) +static int sgirle_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame, AVPacket *avpkt) { SGIRLEContext *s = avctx->priv_data; int ret; @@ -118,11 +126,12 @@ static int sgirle_decode_frame(AVCodecContext *avctx, if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) return ret; - ret = decode_sgirle8(avctx, s->frame->data[0], avpkt->data, avpkt->size, avctx->width, avctx->height, s->frame->linesize[0]); + ret = decode_sgirle8(avctx, s->frame->data[0], avpkt->data, avpkt->size, + avctx->width, avctx->height, s->frame->linesize[0]); if (ret < 0) return ret; - *got_frame = 1; + *got_frame = 1; if ((ret = av_frame_ref(data, s->frame)) < 0) return ret; @@ -140,7 +149,7 @@ static av_cold int sgirle_decode_end(AVCodecContext *avctx) AVCodec ff_sgirle_decoder = { .name = "sgirle", - .long_name = NULL_IF_CONFIG_SMALL("SGI RLE 8-bit"), + .long_name = NULL_IF_CONFIG_SMALL("Silicon Graphics RLE 8-bit video"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_SGIRLE, .priv_data_size = sizeof(SGIRLEContext), diff --git a/libavcodec/utils.c b/libavcodec/utils.c index ad1aae677a..00efa12d99 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2690,6 +2690,7 @@ static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id) case AV_CODEC_ID_WEBP_DEPRECATED : return AV_CODEC_ID_WEBP; case AV_CODEC_ID_HEVC_DEPRECATED : return AV_CODEC_ID_HEVC; case AV_CODEC_ID_SANM_DEPRECATED : return AV_CODEC_ID_SANM; + case AV_CODEC_ID_SGIRLE_DEPRECATED : return AV_CODEC_ID_SGIRLE; case AV_CODEC_ID_VP7_DEPRECATED : return AV_CODEC_ID_VP7; default : return id; } diff --git a/libavcodec/version.h b/libavcodec/version.h index 3fbf8ab208..23c7a8516b 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -30,7 +30,7 @@ #define LIBAVCODEC_VERSION_MAJOR 55 #define LIBAVCODEC_VERSION_MINOR 58 -#define LIBAVCODEC_VERSION_MICRO 103 +#define LIBAVCODEC_VERSION_MICRO 104 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ |