[FFmpeg-devel] [PATCH 2/2] avcodec: add Screen Recorder Gold Codec decoder
Paul B Mahol
onemda at gmail.com
Sun Apr 16 19:48:05 EEST 2017
Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
configure | 1 +
libavcodec/Makefile | 1 +
libavcodec/allcodecs.c | 1 +
libavcodec/avcodec.h | 1 +
libavcodec/codec_desc.c | 7 +++++++
libavcodec/mscc.c | 24 +++++++++++++++++++++---
libavformat/riff.c | 1 +
7 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index 6d4eb2b..6f0d3ba 100755
--- a/configure
+++ b/configure
@@ -2531,6 +2531,7 @@ sonic_decoder_select="golomb rangecoder"
sonic_encoder_select="golomb rangecoder"
sonic_ls_encoder_select="golomb rangecoder"
sp5x_decoder_select="mjpeg_decoder"
+srgc_decoder_select="zlib"
svq1_decoder_select="hpeldsp"
svq1_encoder_select="aandcttables hpeldsp me_cmp mpegvideoenc"
svq3_decoder_select="golomb h264dsp h264parse h264pred hpeldsp tpeldsp videodsp"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index cf5317d..86bc8fd 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -541,6 +541,7 @@ OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o
OBJS-$(CONFIG_SONIC_LS_ENCODER) += sonic.o
OBJS-$(CONFIG_SPEEDHQ_DECODER) += speedhq.o simple_idct.o
OBJS-$(CONFIG_SP5X_DECODER) += sp5xdec.o
+OBJS-$(CONFIG_SRGC_DECODER) += mscc.o
OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o htmlsubtitles.o
OBJS-$(CONFIG_SRT_ENCODER) += srtenc.o ass_split.o
OBJS-$(CONFIG_STL_DECODER) += textdec.o ass.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 5a708b3..7fcc26f 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -317,6 +317,7 @@ static void register_all(void)
REGISTER_ENCDEC (SNOW, snow);
REGISTER_DECODER(SP5X, sp5x);
REGISTER_DECODER(SPEEDHQ, speedhq);
+ REGISTER_DECODER(SRGC, srgc);
REGISTER_ENCDEC (SUNRAST, sunrast);
REGISTER_ENCDEC (SVQ1, svq1);
REGISTER_DECODER(SVQ3, svq3);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index da9d9dc..fc928a1 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -444,6 +444,7 @@ enum AVCodecID {
AV_CODEC_ID_AV1,
AV_CODEC_ID_BITPACKED,
AV_CODEC_ID_MSCC,
+ AV_CODEC_ID_SRGC,
/* various PCM "codecs" */
AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index e342db7..2d28f84 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1395,6 +1395,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("Mandsoft Screen Capture Codec"),
.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
},
+ {
+ .id = AV_CODEC_ID_SRGC,
+ .type = AVMEDIA_TYPE_VIDEO,
+ .name = "srgc",
+ .long_name = NULL_IF_CONFIG_SMALL("Screen Recorder Gold Codec"),
+ .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+ },
/* image codecs */
{
diff --git a/libavcodec/mscc.c b/libavcodec/mscc.c
index c42889a..6e4dbb0 100644
--- a/libavcodec/mscc.c
+++ b/libavcodec/mscc.c
@@ -121,6 +121,8 @@ static int decode_frame(AVCodecContext *avctx,
{
MSCCContext *s = avctx->priv_data;
AVFrame *frame = data;
+ uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
GetByteContext gb;
PutByteContext pb;
int ret, j;
@@ -130,15 +132,19 @@ static int decode_frame(AVCodecContext *avctx,
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
- avpkt->data[2] ^= avpkt->data[0];
+ if (avctx->codec_id == AV_CODEC_ID_MSCC) {
+ avpkt->data[2] ^= avpkt->data[0];
+ buf += 2;
+ buf_size -= 2;
+ }
ret = inflateReset(&s->zstream);
if (ret != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret);
return AVERROR_UNKNOWN;
}
- s->zstream.next_in = avpkt->data + 2;
- s->zstream.avail_in = avpkt->size - 2;
+ s->zstream.next_in = buf;
+ s->zstream.avail_in = buf_size;
s->zstream.next_out = s->decomp_buf;
s->zstream.avail_out = s->decomp_size;
ret = inflate(&s->zstream, Z_FINISH);
@@ -229,3 +235,15 @@ AVCodec ff_mscc_decoder = {
.decode = decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
};
+
+AVCodec ff_srgc_decoder = {
+ .name = "srgc",
+ .long_name = NULL_IF_CONFIG_SMALL("Screen Recorder Gold Codec"),
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_SRGC,
+ .priv_data_size = sizeof(MSCCContext),
+ .init = decode_init,
+ .close = decode_close,
+ .decode = decode_frame,
+ .capabilities = AV_CODEC_CAP_DR1,
+};
diff --git a/libavformat/riff.c b/libavformat/riff.c
index 294d11b..ac902fd 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -453,6 +453,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
{ AV_CODEC_ID_CLEARVIDEO, MKTAG('U', 'C', 'O', 'D') },
{ AV_CODEC_ID_AV1, MKTAG('A', 'V', '0', '1') },
{ AV_CODEC_ID_MSCC, MKTAG('M', 'S', 'C', 'C') },
+ { AV_CODEC_ID_SRGC, MKTAG('S', 'R', 'G', 'C') },
{ AV_CODEC_ID_NONE, 0 }
};
--
2.9.3
More information about the ffmpeg-devel
mailing list