Re: [FFmpeg-devel] [PATCH] avcodec: add RemotelyAnywhere Screen Capture decoder

2018-09-08 Thread Paul B Mahol
On 9/7/18, Michael Niedermayer  wrote:
> On Thu, Sep 06, 2018 at 10:05:50PM +0200, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  configure   |   1 +
>>  libavcodec/Makefile |   1 +
>>  libavcodec/allcodecs.c  |   1 +
>>  libavcodec/avcodec.h|   1 +
>>  libavcodec/codec_desc.c |   7 +
>>  libavcodec/rasc.c   | 789 
>>  libavformat/riff.c  |   1 +
>>  7 files changed, 801 insertions(+)
>>  create mode 100644 libavcodec/rasc.c
> [...]
>> +static int decode_dlta(AVCodecContext *avctx,
>> +   AVPacket *avpkt, unsigned size)
>> +{
>> +RASCContext *s = avctx->priv_data;
>> +GetByteContext *gb = >gb;
>> +GetByteContext dc;
>> +unsigned uncompressed_size, pos;
>> +unsigned x, y, w, h;
>> +int ret, cx, cy, compression;
>> +uint8_t *b1, *b2;
>> +
>> +pos = bytestream2_tell(gb);
>> +bytestream2_skip(gb, 12);
>> +uncompressed_size = bytestream2_get_le32(gb);
>> +x = bytestream2_get_le32(gb);
>> +y = bytestream2_get_le32(gb);
>> +w = bytestream2_get_le32(gb);
>> +h = bytestream2_get_le32(gb);
>> +
>> +if (x >= avctx->width || y >= avctx->height ||
>> +w > avctx->width || h > avctx->height)
>> +return AVERROR_INVALIDDATA;
>> +
>> +if (x + w > avctx->width || y + h > avctx->height)
>> +return AVERROR_INVALIDDATA;
>> +
>> +bytestream2_skip(gb, 4);
>> +compression = bytestream2_get_le32(gb);
>> +
>> +if (compression == 1) {
>> +ret = decode_zlib(avctx, avpkt, size, uncompressed_size);
>> +if (ret < 0)
>> +return ret;
>> +bytestream2_init(, s->delta, uncompressed_size);
>> +} else if (compression == 0) {
>> +if (bytestream2_get_bytes_left(gb) < uncompressed_size)
>> +return AVERROR_INVALIDDATA;
>> +bytestream2_init(, avpkt->data + bytestream2_tell(gb),
>> + uncompressed_size);
>> +} else if (compression == 2) {
>> +avpriv_request_sample(avctx, "compression %d", compression);
>> +return AVERROR_PATCHWELCOME;
>> +} else {
>> +return AVERROR_INVALIDDATA;
>> +}
>> +
>> +if (!s->frame2->data[0] || !s->frame1->data[0])
>> +return AVERROR_INVALIDDATA;
>> +
>> +b1  = s->frame1->data[0] + s->frame1->linesize[0] * (y + h - 1) + x *
>> s->bpp;
>> +b2  = s->frame2->data[0] + s->frame2->linesize[0] * (y + h - 1) + x *
>> s->bpp;
>> +cx = 0, cy = h;
>> +while (bytestream2_get_bytes_left() > 0) {
>> +int type = bytestream2_get_byte();
>> +int len = bytestream2_get_byte();
>> +unsigned fill;
>> +
>> +switch (type) {
>> +case 1:
>> +while (len > 0 && cy > 0) {
>> +cx++;
>> +NEXT_LINE
>> +}
>> +break;
>> +case 2:
>> +while (len > 0 && cy > 0) {
>> +int v0 = b1[cx];
>> +int v1 = b2[cx];
>> +
>> +b2[cx] = v0;
>> +b1[cx] = v1;
>> +cx++;
>> +NEXT_LINE
>> +}
>> +break;
>> +case 3:
>> +while (len > 0 && cy > 0) {
>> +fill = bytestream2_get_byte();
>> +b1[cx] = b2[cx];
>> +b2[cx] = fill;
>> +cx++;
>> +NEXT_LINE
>> +}
>> +break;
>> +case 4:
>> +fill = bytestream2_get_byte();
>> +while (len > 0 && cy > 0) {
>> +AV_WL32(b1 + cx, AV_RL32(b2 + cx));
>> +AV_WL32(b2 + cx, fill);
>> +cx++;
>> +NEXT_LINE
>> +}
>> +break;
>> +case 7:
>> +fill = bytestream2_get_le32();
>> +while (len > 0 && cy > 0) {
>> +AV_WL32(b1 + cx, AV_RL32(b2 + cx));
>> +AV_WL32(b2 + cx, fill);
>> +cx += 4;
>> +NEXT_LINE
>> +}
>> +break;
>> +case 10:
>> +while (len > 0 && cy > 0) {
>> +cx += 4;
>> +NEXT_LINE
>> +}
>> +break;
>> +case 12:
>> +while (len > 0 && cy > 0) {
>> +unsigned v0, v1;
>> +
>> +v0 = AV_RL32(b2 + cx);
>> +v1 = AV_RL32(b1 + cx);
>> +AV_WL32(b2 + cx, v1);
>> +AV_WL32(b1 + cx, v0);
>> +cx += 4;
>> +NEXT_LINE
>> +}
>> +break;
>> +case 13:
>> +while (len > 0 && cy > 0) {
>> +fill = bytestream2_get_le32();
>> +AV_WL32(b1 + cx, AV_RL32(b2 + cx));
>> +AV_WL32(b2 + cx, fill);
>> +cx += 4;
>> +NEXT_LINE
>> +}
>> +break;
>> +default:
>
>> +printf("%d 

Re: [FFmpeg-devel] [PATCH] avcodec: add RemotelyAnywhere Screen Capture decoder

2018-09-06 Thread Michael Niedermayer
On Thu, Sep 06, 2018 at 10:05:50PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  configure   |   1 +
>  libavcodec/Makefile |   1 +
>  libavcodec/allcodecs.c  |   1 +
>  libavcodec/avcodec.h|   1 +
>  libavcodec/codec_desc.c |   7 +
>  libavcodec/rasc.c   | 789 
>  libavformat/riff.c  |   1 +
>  7 files changed, 801 insertions(+)
>  create mode 100644 libavcodec/rasc.c
[...]
> +static int decode_dlta(AVCodecContext *avctx,
> +   AVPacket *avpkt, unsigned size)
> +{
> +RASCContext *s = avctx->priv_data;
> +GetByteContext *gb = >gb;
> +GetByteContext dc;
> +unsigned uncompressed_size, pos;
> +unsigned x, y, w, h;
> +int ret, cx, cy, compression;
> +uint8_t *b1, *b2;
> +
> +pos = bytestream2_tell(gb);
> +bytestream2_skip(gb, 12);
> +uncompressed_size = bytestream2_get_le32(gb);
> +x = bytestream2_get_le32(gb);
> +y = bytestream2_get_le32(gb);
> +w = bytestream2_get_le32(gb);
> +h = bytestream2_get_le32(gb);
> +
> +if (x >= avctx->width || y >= avctx->height ||
> +w > avctx->width || h > avctx->height)
> +return AVERROR_INVALIDDATA;
> +
> +if (x + w > avctx->width || y + h > avctx->height)
> +return AVERROR_INVALIDDATA;
> +
> +bytestream2_skip(gb, 4);
> +compression = bytestream2_get_le32(gb);
> +
> +if (compression == 1) {
> +ret = decode_zlib(avctx, avpkt, size, uncompressed_size);
> +if (ret < 0)
> +return ret;
> +bytestream2_init(, s->delta, uncompressed_size);
> +} else if (compression == 0) {
> +if (bytestream2_get_bytes_left(gb) < uncompressed_size)
> +return AVERROR_INVALIDDATA;
> +bytestream2_init(, avpkt->data + bytestream2_tell(gb),
> + uncompressed_size);
> +} else if (compression == 2) {
> +avpriv_request_sample(avctx, "compression %d", compression);
> +return AVERROR_PATCHWELCOME;
> +} else {
> +return AVERROR_INVALIDDATA;
> +}
> +
> +if (!s->frame2->data[0] || !s->frame1->data[0])
> +return AVERROR_INVALIDDATA;
> +
> +b1  = s->frame1->data[0] + s->frame1->linesize[0] * (y + h - 1) + x * 
> s->bpp;
> +b2  = s->frame2->data[0] + s->frame2->linesize[0] * (y + h - 1) + x * 
> s->bpp;
> +cx = 0, cy = h;
> +while (bytestream2_get_bytes_left() > 0) {
> +int type = bytestream2_get_byte();
> +int len = bytestream2_get_byte();
> +unsigned fill;
> +
> +switch (type) {
> +case 1:
> +while (len > 0 && cy > 0) {
> +cx++;
> +NEXT_LINE
> +}
> +break;
> +case 2:
> +while (len > 0 && cy > 0) {
> +int v0 = b1[cx];
> +int v1 = b2[cx];
> +
> +b2[cx] = v0;
> +b1[cx] = v1;
> +cx++;
> +NEXT_LINE
> +}
> +break;
> +case 3:
> +while (len > 0 && cy > 0) {
> +fill = bytestream2_get_byte();
> +b1[cx] = b2[cx];
> +b2[cx] = fill;
> +cx++;
> +NEXT_LINE
> +}
> +break;
> +case 4:
> +fill = bytestream2_get_byte();
> +while (len > 0 && cy > 0) {
> +AV_WL32(b1 + cx, AV_RL32(b2 + cx));
> +AV_WL32(b2 + cx, fill);
> +cx++;
> +NEXT_LINE
> +}
> +break;
> +case 7:
> +fill = bytestream2_get_le32();
> +while (len > 0 && cy > 0) {
> +AV_WL32(b1 + cx, AV_RL32(b2 + cx));
> +AV_WL32(b2 + cx, fill);
> +cx += 4;
> +NEXT_LINE
> +}
> +break;
> +case 10:
> +while (len > 0 && cy > 0) {
> +cx += 4;
> +NEXT_LINE
> +}
> +break;
> +case 12:
> +while (len > 0 && cy > 0) {
> +unsigned v0, v1;
> +
> +v0 = AV_RL32(b2 + cx);
> +v1 = AV_RL32(b1 + cx);
> +AV_WL32(b2 + cx, v1);
> +AV_WL32(b1 + cx, v0);
> +cx += 4;
> +NEXT_LINE
> +}
> +break;
> +case 13:
> +while (len > 0 && cy > 0) {
> +fill = bytestream2_get_le32();
> +AV_WL32(b1 + cx, AV_RL32(b2 + cx));
> +AV_WL32(b2 + cx, fill);
> +cx += 4;
> +NEXT_LINE
> +}
> +break;
> +default:

> +printf("%d %d\n", type, bytestream2_tell());
> +bytestream2_seek(, 0, SEEK_SET);
> +for (int i = 0; bytestream2_get_bytes_left() > 0; i++)
> +printf("%02X ", 

[FFmpeg-devel] [PATCH] avcodec: add RemotelyAnywhere Screen Capture decoder

2018-09-06 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 configure   |   1 +
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/avcodec.h|   1 +
 libavcodec/codec_desc.c |   7 +
 libavcodec/rasc.c   | 789 
 libavformat/riff.c  |   1 +
 7 files changed, 801 insertions(+)
 create mode 100644 libavcodec/rasc.c

diff --git a/configure b/configure
index 0d6ee0abfc..595be65f2c 100755
--- a/configure
+++ b/configure
@@ -2719,6 +2719,7 @@ qdm2_decoder_select="mdct rdft mpegaudiodsp"
 ra_144_decoder_select="audiodsp"
 ra_144_encoder_select="audio_frame_queue lpc audiodsp"
 ralf_decoder_select="golomb"
+rasc_decoder_deps="zlib"
 rawvideo_decoder_select="bswapdsp"
 rscc_decoder_deps="zlib"
 rtjpeg_decoder_select="me_cmp"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f8673f0121..ceec1df972 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -536,6 +536,7 @@ OBJS-$(CONFIG_RA_144_DECODER)  += ra144dec.o 
ra144.o celp_filters.o
 OBJS-$(CONFIG_RA_144_ENCODER)  += ra144enc.o ra144.o celp_filters.o
 OBJS-$(CONFIG_RA_288_DECODER)  += ra288.o celp_filters.o
 OBJS-$(CONFIG_RALF_DECODER)+= ralf.o
+OBJS-$(CONFIG_RASC_DECODER)+= rasc.o
 OBJS-$(CONFIG_RAWVIDEO_DECODER)+= rawdec.o
 OBJS-$(CONFIG_RAWVIDEO_ENCODER)+= rawenc.o
 OBJS-$(CONFIG_REALTEXT_DECODER)+= realtextdec.o ass.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index a461131c78..8fc1aeab79 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -248,6 +248,7 @@ extern AVCodec ff_r10k_encoder;
 extern AVCodec ff_r10k_decoder;
 extern AVCodec ff_r210_encoder;
 extern AVCodec ff_r210_decoder;
+extern AVCodec ff_rasc_decoder;
 extern AVCodec ff_rawvideo_encoder;
 extern AVCodec ff_rawvideo_decoder;
 extern AVCodec ff_rl2_decoder;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index b6688b7af3..719c181a08 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -451,6 +451,7 @@ enum AVCodecID {
 AV_CODEC_ID_PROSUMER,
 AV_CODEC_ID_MWSC,
 AV_CODEC_ID_WCMV,
+AV_CODEC_ID_RASC,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 46dfe3f5e5..67a30542d1 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1682,6 +1682,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("WinCAM Motion Video"),
 .props = AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_RASC,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "rasc",
+.long_name = NULL_IF_CONFIG_SMALL("RemotelyAnywhere Screen Capture"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/rasc.c b/libavcodec/rasc.c
new file mode 100644
index 00..1b420c4131
--- /dev/null
+++ b/libavcodec/rasc.c
@@ -0,0 +1,789 @@
+/*
+ * RemotelyAnywhere Screen Capture decoder
+ *
+ * Copyright (c) 2018 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include 
+
+#include "libavutil/avassert.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#include 
+
+#define KBND MKTAG('K', 'B', 'N', 'D')
+#define FINT MKTAG('F', 'I', 'N', 'T')
+#define INIT MKTAG('I', 'N', 'I', 'T')
+#define BNDL MKTAG('B', 'N', 'D', 'L')
+#define KFRM MKTAG('K', 'F', 'R', 'M')
+#define DLTA MKTAG('D', 'L', 'T', 'A')
+#define MOUS MKTAG('M', 'O', 'U', 'S')
+#define MPOS MKTAG('M', 'P', 'O', 'S')
+#define MOVE MKTAG('M', 'O', 'V', 'E')
+#define EMPT MKTAG('E', 'M', 'P', 'T')
+
+typedef struct RASCContext {
+AVClass*class;
+int skip_cursor;
+GetByteContext  gb;
+uint8_t*delta;
+int delta_size;
+uint8_t*cursor;
+int cursor_size;
+unsignedcursor_w;
+unsignedcursor_h;
+unsignedcursor_x;
+unsignedcursor_y;
+int stride;
+int

[FFmpeg-devel] [PATCH] avcodec: add RemotelyAnywhere Screen Capture decoder

2018-09-05 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 configure   |   1 +
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/avcodec.h|   1 +
 libavcodec/codec_desc.c |   7 +
 libavcodec/rasc.c   | 795 
 libavformat/riff.c  |   1 +
 7 files changed, 807 insertions(+)
 create mode 100644 libavcodec/rasc.c

diff --git a/configure b/configure
index 0d6ee0abfc..595be65f2c 100755
--- a/configure
+++ b/configure
@@ -2719,6 +2719,7 @@ qdm2_decoder_select="mdct rdft mpegaudiodsp"
 ra_144_decoder_select="audiodsp"
 ra_144_encoder_select="audio_frame_queue lpc audiodsp"
 ralf_decoder_select="golomb"
+rasc_decoder_deps="zlib"
 rawvideo_decoder_select="bswapdsp"
 rscc_decoder_deps="zlib"
 rtjpeg_decoder_select="me_cmp"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f8673f0121..ceec1df972 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -536,6 +536,7 @@ OBJS-$(CONFIG_RA_144_DECODER)  += ra144dec.o 
ra144.o celp_filters.o
 OBJS-$(CONFIG_RA_144_ENCODER)  += ra144enc.o ra144.o celp_filters.o
 OBJS-$(CONFIG_RA_288_DECODER)  += ra288.o celp_filters.o
 OBJS-$(CONFIG_RALF_DECODER)+= ralf.o
+OBJS-$(CONFIG_RASC_DECODER)+= rasc.o
 OBJS-$(CONFIG_RAWVIDEO_DECODER)+= rawdec.o
 OBJS-$(CONFIG_RAWVIDEO_ENCODER)+= rawenc.o
 OBJS-$(CONFIG_REALTEXT_DECODER)+= realtextdec.o ass.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index a461131c78..8fc1aeab79 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -248,6 +248,7 @@ extern AVCodec ff_r10k_encoder;
 extern AVCodec ff_r10k_decoder;
 extern AVCodec ff_r210_encoder;
 extern AVCodec ff_r210_decoder;
+extern AVCodec ff_rasc_decoder;
 extern AVCodec ff_rawvideo_encoder;
 extern AVCodec ff_rawvideo_decoder;
 extern AVCodec ff_rl2_decoder;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index b6688b7af3..719c181a08 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -451,6 +451,7 @@ enum AVCodecID {
 AV_CODEC_ID_PROSUMER,
 AV_CODEC_ID_MWSC,
 AV_CODEC_ID_WCMV,
+AV_CODEC_ID_RASC,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 46dfe3f5e5..67a30542d1 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1682,6 +1682,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("WinCAM Motion Video"),
 .props = AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_RASC,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "rasc",
+.long_name = NULL_IF_CONFIG_SMALL("RemotelyAnywhere Screen Capture"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/rasc.c b/libavcodec/rasc.c
new file mode 100644
index 00..a50075388a
--- /dev/null
+++ b/libavcodec/rasc.c
@@ -0,0 +1,795 @@
+/*
+ * RemotelyAnywhere Screen Capture decoder
+ *
+ * Copyright (c) 2018 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include 
+
+#include "libavutil/avassert.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#include 
+
+#define KBND MKTAG('K', 'B', 'N', 'D')
+#define FINT MKTAG('F', 'I', 'N', 'T')
+#define INIT MKTAG('I', 'N', 'I', 'T')
+#define BNDL MKTAG('B', 'N', 'D', 'L')
+#define KFRM MKTAG('K', 'F', 'R', 'M')
+#define DLTA MKTAG('D', 'L', 'T', 'A')
+#define MOUS MKTAG('M', 'O', 'U', 'S')
+#define MPOS MKTAG('M', 'P', 'O', 'S')
+#define MOVE MKTAG('M', 'O', 'V', 'E')
+#define EMPT MKTAG('E', 'M', 'P', 'T')
+
+typedef struct RASCContext {
+AVClass*class;
+int skip_cursor;
+GetByteContext  gb;
+uint8_t*delta;
+int delta_size;
+uint8_t*cursor;
+int cursor_size;
+unsignedcursor_w;
+unsignedcursor_h;
+unsignedcursor_x;
+unsignedcursor_y;
+z_streamzstream;
+AVFrame   

Re: [FFmpeg-devel] [PATCH] avcodec: add RemotelyAnywhere Screen Capture decoder

2018-09-04 Thread Michael Niedermayer
On Tue, Sep 04, 2018 at 03:57:05PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/Makefile |   1 +
>  libavcodec/allcodecs.c  |   1 +
>  libavcodec/avcodec.h|   1 +
>  libavcodec/codec_desc.c |   7 +
>  libavcodec/rasc.c   | 590 
>  libavformat/riff.c  |   1 +
>  6 files changed, 601 insertions(+)
>  create mode 100644 libavcodec/rasc.c
[...]
{
> diff --git a/libavcodec/rasc.c b/libavcodec/rasc.c
> new file mode 100644
> index 00..288fe53a21
> --- /dev/null
> +++ b/libavcodec/rasc.c
> @@ -0,0 +1,590 @@
> +/*
> + * RemotelyAnywhere Screen Capture decoder
> + *
> + * Copyright (c) 2018 Paul B Mahol
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +#include "libavutil/avassert.h"
> +#include "libavutil/imgutils.h"
> +
> +#include "avcodec.h"
> +#include "bytestream.h"
> +#include "internal.h"
> +
> +#include 

this is missing a dependancy or #if on zlib


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec: add RemotelyAnywhere Screen Capture decoder

2018-09-04 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/avcodec.h|   1 +
 libavcodec/codec_desc.c |   7 +
 libavcodec/rasc.c   | 590 
 libavformat/riff.c  |   1 +
 6 files changed, 601 insertions(+)
 create mode 100644 libavcodec/rasc.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f8673f0121..ceec1df972 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -536,6 +536,7 @@ OBJS-$(CONFIG_RA_144_DECODER)  += ra144dec.o 
ra144.o celp_filters.o
 OBJS-$(CONFIG_RA_144_ENCODER)  += ra144enc.o ra144.o celp_filters.o
 OBJS-$(CONFIG_RA_288_DECODER)  += ra288.o celp_filters.o
 OBJS-$(CONFIG_RALF_DECODER)+= ralf.o
+OBJS-$(CONFIG_RASC_DECODER)+= rasc.o
 OBJS-$(CONFIG_RAWVIDEO_DECODER)+= rawdec.o
 OBJS-$(CONFIG_RAWVIDEO_ENCODER)+= rawenc.o
 OBJS-$(CONFIG_REALTEXT_DECODER)+= realtextdec.o ass.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index a461131c78..8fc1aeab79 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -248,6 +248,7 @@ extern AVCodec ff_r10k_encoder;
 extern AVCodec ff_r10k_decoder;
 extern AVCodec ff_r210_encoder;
 extern AVCodec ff_r210_decoder;
+extern AVCodec ff_rasc_decoder;
 extern AVCodec ff_rawvideo_encoder;
 extern AVCodec ff_rawvideo_decoder;
 extern AVCodec ff_rl2_decoder;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index b6688b7af3..719c181a08 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -451,6 +451,7 @@ enum AVCodecID {
 AV_CODEC_ID_PROSUMER,
 AV_CODEC_ID_MWSC,
 AV_CODEC_ID_WCMV,
+AV_CODEC_ID_RASC,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 46dfe3f5e5..67a30542d1 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1682,6 +1682,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("WinCAM Motion Video"),
 .props = AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_RASC,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "rasc",
+.long_name = NULL_IF_CONFIG_SMALL("RemotelyAnywhere Screen Capture"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/rasc.c b/libavcodec/rasc.c
new file mode 100644
index 00..288fe53a21
--- /dev/null
+++ b/libavcodec/rasc.c
@@ -0,0 +1,590 @@
+/*
+ * RemotelyAnywhere Screen Capture decoder
+ *
+ * Copyright (c) 2018 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include 
+
+#include "libavutil/avassert.h"
+#include "libavutil/imgutils.h"
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#include 
+
+#define KBND MKTAG('K', 'B', 'N', 'D')
+#define FINT MKTAG('F', 'I', 'N', 'T')
+#define BNDL MKTAG('B', 'N', 'D', 'L')
+#define KFRM MKTAG('K', 'F', 'R', 'M')
+#define DLTA MKTAG('D', 'L', 'T', 'A')
+#define MOUS MKTAG('M', 'O', 'U', 'S') /* TODO */
+#define MPOS MKTAG('M', 'P', 'O', 'S') /* TODO */
+#define MOVE MKTAG('M', 'O', 'V', 'E') /* TODO */
+#define EMPT MKTAG('E', 'M', 'P', 'T')
+
+typedef struct RASCContext {
+GetByteContext  gb;
+uint8_t*delta;
+int delta_size;
+int bndl;
+z_streamzstream;
+AVFrame*frame;
+AVFrame*frame1;
+AVFrame*frame2;
+} RASCContext;
+
+static void clear_plane(AVCodecContext *avctx, AVFrame *frame)
+{
+uint8_t *dst = frame->data[0];
+
+for (int y = 0; y < avctx->height; y++) {
+memset(dst, 0, avctx->width);
+dst += frame->linesize[0];
+}
+}
+
+static int decode_fint(AVCodecContext *avctx, AVFrame *frame,
+   AVPacket *avpkt, unsigned size)
+{
+RASCContext *s = avctx->priv_data;
+GetByteContext *gb = >gb;
+unsigned w, h;
+uint32_t *pal;
+int ret;
+
+clear_plane(avctx, frame);
+bytestream2_skip(gb, 8);
+w = bytestream2_get_le32(gb);
+h =