* 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>
... | ... |
@@ -236,7 +236,7 @@ version 1.1: |
236 | 236 |
- JSON captions for TED talks decoding support |
237 | 237 |
- SOX Resampler support in libswresample |
238 | 238 |
- aselect filter |
239 |
-- SGI RLE 8-bit decoder |
|
239 |
+- SGI RLE 8-bit / Silicon Graphics RLE 8-bit video decoder |
|
240 | 240 |
- Silicon Graphics Motion Video Compressor 1 & 2 decoder |
241 | 241 |
- Silicon Graphics Movie demuxer |
242 | 242 |
- apad filter |
... | ... |
@@ -752,11 +752,11 @@ following image formats are supported: |
752 | 752 |
@tab Texture dictionaries used by the Renderware Engine. |
753 | 753 |
@item RL2 video @tab @tab X |
754 | 754 |
@tab used in some games by Entertainment Software Partners |
755 |
-@item SGI RLE 8-bit @tab @tab X |
|
756 | 755 |
@item Sierra VMD video @tab @tab X |
757 | 756 |
@tab Used in Sierra VMD files. |
758 | 757 |
@item Silicon Graphics Motion Video Compressor 1 (MVC1) @tab @tab X |
759 | 758 |
@item Silicon Graphics Motion Video Compressor 2 (MVC2) @tab @tab X |
759 |
+@item Silicon Graphics RLE 8-bit video @tab @tab X |
|
760 | 760 |
@item Smacker video @tab @tab X |
761 | 761 |
@tab Video encoding used in Smacker. |
762 | 762 |
@item SMPTE VC-1 @tab @tab X |
... | ... |
@@ -292,6 +292,7 @@ enum AVCodecID { |
292 | 292 |
AV_CODEC_ID_EXR_DEPRECATED, |
293 | 293 |
AV_CODEC_ID_VP7_DEPRECATED, |
294 | 294 |
AV_CODEC_ID_SANM_DEPRECATED, |
295 |
+ AV_CODEC_ID_SGIRLE_DEPRECATED, |
|
295 | 296 |
|
296 | 297 |
AV_CODEC_ID_BRENDER_PIX= MKBETAG('B','P','I','X'), |
297 | 298 |
AV_CODEC_ID_Y41P = MKBETAG('Y','4','1','P'), |
... | ... |
@@ -662,13 +662,6 @@ static const AVCodecDescriptor codec_descriptors[] = { |
662 | 662 |
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, |
663 | 663 |
}, |
664 | 664 |
{ |
665 |
- .id = AV_CODEC_ID_SGIRLE, |
|
666 |
- .type = AVMEDIA_TYPE_VIDEO, |
|
667 |
- .name = "sgirle", |
|
668 |
- .long_name = NULL_IF_CONFIG_SMALL("SGI RLE 8-bit"), |
|
669 |
- .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, |
|
670 |
- }, |
|
671 |
- { |
|
672 | 665 |
.id = AV_CODEC_ID_C93, |
673 | 666 |
.type = AVMEDIA_TYPE_VIDEO, |
674 | 667 |
.name = "c93", |
... | ... |
@@ -1233,6 +1226,13 @@ static const AVCodecDescriptor codec_descriptors[] = { |
1233 | 1233 |
.long_name = NULL_IF_CONFIG_SMALL("LucasArts SANM/SMUSH video"), |
1234 | 1234 |
.props = AV_CODEC_PROP_LOSSY, |
1235 | 1235 |
}, |
1236 |
+ { |
|
1237 |
+ .id = AV_CODEC_ID_SGIRLE, |
|
1238 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
1239 |
+ .name = "sgirle", |
|
1240 |
+ .long_name = NULL_IF_CONFIG_SMALL("SGI RLE 8-bit"), |
|
1241 |
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, |
|
1242 |
+ }, |
|
1236 | 1243 |
|
1237 | 1244 |
/* image codecs */ |
1238 | 1245 |
{ |
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
/* |
2 |
- * SGI RLE 8-bit decoder |
|
2 |
+ * Silicon Graphics RLE 8-bit video decoder |
|
3 | 3 |
* Copyright (c) 2012 Peter Ross |
4 | 4 |
* |
5 | 5 |
* This file is part of FFmpeg. |
... | ... |
@@ -21,9 +21,13 @@ |
21 | 21 |
|
22 | 22 |
/** |
23 | 23 |
* @file |
24 |
- * SGI RLE 8-bit decoder |
|
24 |
+ * Silicon Graphics RLE 8-bit video decoder |
|
25 |
+ * @note Data is packed in rbg323 with rle, contained in mv or mov. |
|
26 |
+ * The algorithm and pixfmt are subtly different from SGI images. |
|
25 | 27 |
*/ |
26 | 28 |
|
29 |
+#include "libavutil/common.h" |
|
30 |
+ |
|
27 | 31 |
#include "avcodec.h" |
28 | 32 |
#include "internal.h" |
29 | 33 |
|
... | ... |
@@ -42,39 +46,44 @@ static av_cold int sgirle_decode_init(AVCodecContext *avctx) |
42 | 42 |
} |
43 | 43 |
|
44 | 44 |
/** |
45 |
- * Convert SGI RGB332 pixel into AV_PIX_FMT_BGR8 |
|
46 |
- * SGI RGB332 is packed RGB 3:3:2, 8bpp, (msb)3R 2B 3G(lsb) |
|
45 |
+ * Convert SGI RBG323 pixel into AV_PIX_FMT_BGR8 |
|
46 |
+ * SGI RGB data is packed as 8bpp, (msb)3R 2B 3G(lsb) |
|
47 | 47 |
*/ |
48 |
-#define RGB332_TO_BGR8(x) (((x << 3) & 0xC0) | ((x << 3) & 0x38) | ((x >> 5) & 7)) |
|
49 |
- |
|
50 |
-static av_always_inline void memcpy_rgb332_to_bgr8(uint8_t *dst, const uint8_t *src, int size) |
|
48 |
+#define RBG323_TO_BGR8(x) (((x << 3) & 0xC0) | \ |
|
49 |
+ ((x << 3) & 0x38) | \ |
|
50 |
+ ((x >> 5) & 7)) |
|
51 |
+static av_always_inline |
|
52 |
+void rbg323_to_bgr8(uint8_t *dst, const uint8_t *src, int size) |
|
51 | 53 |
{ |
52 | 54 |
int i; |
53 | 55 |
for (i = 0; i < size; i++) |
54 |
- dst[i] = RGB332_TO_BGR8(src[i]); |
|
56 |
+ dst[i] = RBG323_TO_BGR8(src[i]); |
|
55 | 57 |
} |
56 | 58 |
|
57 | 59 |
/** |
58 | 60 |
* @param[out] dst Destination buffer |
59 |
- * @param[in] src Source buffer |
|
61 |
+ * @param[in] src Source buffer |
|
60 | 62 |
* @param src_size Source buffer size (bytes) |
61 |
- * @param width Width of destination buffer (pixels) |
|
62 |
- * @param height Height of destination buffer (pixels) |
|
63 |
+ * @param width Width of destination buffer (pixels) |
|
64 |
+ * @param height Height of destination buffer (pixels) |
|
63 | 65 |
* @param linesize Line size of destination buffer (bytes) |
66 |
+ * |
|
64 | 67 |
* @return <0 on error |
65 | 68 |
*/ |
66 |
-static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *src, int src_size, int width, int height, int linesize) |
|
69 |
+static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, |
|
70 |
+ const uint8_t *src, int src_size, |
|
71 |
+ int width, int height, ptrdiff_t linesize) |
|
67 | 72 |
{ |
68 | 73 |
const uint8_t *src_end = src + src_size; |
69 | 74 |
int x = 0, y = 0; |
70 | 75 |
|
71 |
-#define INC_XY(n) \ |
|
72 |
- x += n; \ |
|
73 |
- if (x >= width) { \ |
|
74 |
- y++; \ |
|
75 |
- if (y >= height) \ |
|
76 |
- return 0; \ |
|
77 |
- x = 0; \ |
|
76 |
+#define INC_XY(n) \ |
|
77 |
+ x += n; \ |
|
78 |
+ if (x >= width) { \ |
|
79 |
+ y++; \ |
|
80 |
+ if (y >= height) \ |
|
81 |
+ return 0; \ |
|
82 |
+ x = 0; \ |
|
78 | 83 |
} |
79 | 84 |
|
80 | 85 |
while (src_end - src >= 2) { |
... | ... |
@@ -84,9 +93,9 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *sr |
84 | 84 |
int length = FFMIN(v, width - x); |
85 | 85 |
if (length <= 0) |
86 | 86 |
break; |
87 |
- memset(dst + y*linesize + x, RGB332_TO_BGR8(*src), length); |
|
87 |
+ memset(dst + y * linesize + x, RBG323_TO_BGR8(*src), length); |
|
88 | 88 |
INC_XY(length); |
89 |
- v -= length; |
|
89 |
+ v -= length; |
|
90 | 90 |
} while (v > 0); |
91 | 91 |
src++; |
92 | 92 |
} else if (v >= 0xC1) { |
... | ... |
@@ -95,7 +104,7 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *sr |
95 | 95 |
int length = FFMIN3(v, width - x, src_end - src); |
96 | 96 |
if (src_end - src < length || length <= 0) |
97 | 97 |
break; |
98 |
- memcpy_rgb332_to_bgr8(dst + y*linesize + x, src, length); |
|
98 |
+ rbg323_to_bgr8(dst + y * linesize + x, src, length); |
|
99 | 99 |
INC_XY(length); |
100 | 100 |
src += length; |
101 | 101 |
v -= length; |
... | ... |
@@ -108,9 +117,8 @@ static int decode_sgirle8(AVCodecContext *avctx, uint8_t *dst, const uint8_t *sr |
108 | 108 |
return 0; |
109 | 109 |
} |
110 | 110 |
|
111 |
-static int sgirle_decode_frame(AVCodecContext *avctx, |
|
112 |
- void *data, int *got_frame, |
|
113 |
- AVPacket *avpkt) |
|
111 |
+static int sgirle_decode_frame(AVCodecContext *avctx, void *data, |
|
112 |
+ int *got_frame, AVPacket *avpkt) |
|
114 | 113 |
{ |
115 | 114 |
SGIRLEContext *s = avctx->priv_data; |
116 | 115 |
int ret; |
... | ... |
@@ -118,11 +126,12 @@ static int sgirle_decode_frame(AVCodecContext *avctx, |
118 | 118 |
if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) |
119 | 119 |
return ret; |
120 | 120 |
|
121 |
- ret = decode_sgirle8(avctx, s->frame->data[0], avpkt->data, avpkt->size, avctx->width, avctx->height, s->frame->linesize[0]); |
|
121 |
+ ret = decode_sgirle8(avctx, s->frame->data[0], avpkt->data, avpkt->size, |
|
122 |
+ avctx->width, avctx->height, s->frame->linesize[0]); |
|
122 | 123 |
if (ret < 0) |
123 | 124 |
return ret; |
124 | 125 |
|
125 |
- *got_frame = 1; |
|
126 |
+ *got_frame = 1; |
|
126 | 127 |
if ((ret = av_frame_ref(data, s->frame)) < 0) |
127 | 128 |
return ret; |
128 | 129 |
|
... | ... |
@@ -140,7 +149,7 @@ static av_cold int sgirle_decode_end(AVCodecContext *avctx) |
140 | 140 |
|
141 | 141 |
AVCodec ff_sgirle_decoder = { |
142 | 142 |
.name = "sgirle", |
143 |
- .long_name = NULL_IF_CONFIG_SMALL("SGI RLE 8-bit"), |
|
143 |
+ .long_name = NULL_IF_CONFIG_SMALL("Silicon Graphics RLE 8-bit video"), |
|
144 | 144 |
.type = AVMEDIA_TYPE_VIDEO, |
145 | 145 |
.id = AV_CODEC_ID_SGIRLE, |
146 | 146 |
.priv_data_size = sizeof(SGIRLEContext), |
... | ... |
@@ -2690,6 +2690,7 @@ static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id) |
2690 | 2690 |
case AV_CODEC_ID_WEBP_DEPRECATED : return AV_CODEC_ID_WEBP; |
2691 | 2691 |
case AV_CODEC_ID_HEVC_DEPRECATED : return AV_CODEC_ID_HEVC; |
2692 | 2692 |
case AV_CODEC_ID_SANM_DEPRECATED : return AV_CODEC_ID_SANM; |
2693 |
+ case AV_CODEC_ID_SGIRLE_DEPRECATED : return AV_CODEC_ID_SGIRLE; |
|
2693 | 2694 |
case AV_CODEC_ID_VP7_DEPRECATED : return AV_CODEC_ID_VP7; |
2694 | 2695 |
default : return id; |
2695 | 2696 |
} |
... | ... |
@@ -30,7 +30,7 @@ |
30 | 30 |
|
31 | 31 |
#define LIBAVCODEC_VERSION_MAJOR 55 |
32 | 32 |
#define LIBAVCODEC_VERSION_MINOR 58 |
33 |
-#define LIBAVCODEC_VERSION_MICRO 103 |
|
33 |
+#define LIBAVCODEC_VERSION_MICRO 104 |
|
34 | 34 |
|
35 | 35 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
36 | 36 |
LIBAVCODEC_VERSION_MINOR, \ |