[FFmpeg-devel] [PATCH 2/3] avcodec: add SGA Video decoder
James Almer
jamrial at gmail.com
Sat Feb 27 05:19:02 EET 2021
On 2/26/2021 8:29 AM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
> libavcodec/Makefile | 1 +
> libavcodec/allcodecs.c | 1 +
> libavcodec/codec_desc.c | 7 +
> libavcodec/codec_id.h | 1 +
> libavcodec/sga.c | 534 ++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 544 insertions(+)
> create mode 100644 libavcodec/sga.c
>
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index fe7026c1db..850657ae3c 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -609,6 +609,7 @@ OBJS-$(CONFIG_SANM_DECODER) += sanm.o
> OBJS-$(CONFIG_SCPR_DECODER) += scpr.o
> OBJS-$(CONFIG_SCREENPRESSO_DECODER) += screenpresso.o
> OBJS-$(CONFIG_SDX2_DPCM_DECODER) += dpcm.o
> +OBJS-$(CONFIG_SGA_DECODER) += sga.o
> OBJS-$(CONFIG_SGI_DECODER) += sgidec.o
> OBJS-$(CONFIG_SGI_ENCODER) += sgienc.o rle.o
> OBJS-$(CONFIG_SGIRLE_DECODER) += sgirledec.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 990998b64b..a04faead16 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -289,6 +289,7 @@ extern AVCodec ff_s302m_decoder;
> extern AVCodec ff_sanm_decoder;
> extern AVCodec ff_scpr_decoder;
> extern AVCodec ff_screenpresso_decoder;
> +extern AVCodec ff_sga_decoder;
> extern AVCodec ff_sgi_encoder;
> extern AVCodec ff_sgi_decoder;
> extern AVCodec ff_sgirle_decoder;
> diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
> index f64ba488f2..17f8a14044 100644
> --- a/libavcodec/codec_desc.c
> +++ b/libavcodec/codec_desc.c
> @@ -1849,6 +1849,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
> .long_name = NULL_IF_CONFIG_SMALL("Simbiosis Interactive IMX Video"),
> .props = AV_CODEC_PROP_LOSSY,
> },
> + {
> + .id = AV_CODEC_ID_SGA_VIDEO,
> + .type = AVMEDIA_TYPE_VIDEO,
> + .name = "sga",
> + .long_name = NULL_IF_CONFIG_SMALL("Digital Pictures SGA Video"),
> + .props = AV_CODEC_PROP_LOSSY,
> + },
>
> /* various PCM "codecs" */
> {
> diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
> index 7dd316afd2..ab7bc68ee2 100644
> --- a/libavcodec/codec_id.h
> +++ b/libavcodec/codec_id.h
> @@ -306,6 +306,7 @@ enum AVCodecID {
> AV_CODEC_ID_ARGO,
> AV_CODEC_ID_CRI,
> AV_CODEC_ID_SIMBIOSIS_IMX,
> + AV_CODEC_ID_SGA_VIDEO,
>
> /* various PCM "codecs" */
> AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
> diff --git a/libavcodec/sga.c b/libavcodec/sga.c
> new file mode 100644
> index 0000000000..00752a5843
> --- /dev/null
> +++ b/libavcodec/sga.c
sgadec.c?
[...]
> + memcpy(frame->data[1], s->pal, AVPALETTE_SIZE);
> + frame->palette_has_changed = 1;
> + frame->pict_type = AV_PICTURE_TYPE_I;
Missing intra only in codec_desc.c, then?
> + frame->key_frame = 1;
The demuxer does not seem to set every packet as key frame, only some.
Which is it?
> +
> + *got_frame = 1;
> +
> + return avpkt->size;
> +}
> +
> +static av_cold int sga_decode_end(AVCodecContext *avctx)
> +{
> + SGAVideoContext *s = avctx->priv_data;
> +
> + av_freep(&s->tileindex_data);
> + s->tileindex_size = 0;
> +
> + av_freep(&s->palmapindex_data);
> + s->palmapindex_size = 0;
> +
> + return 0;
> +}
> +
> +AVCodec ff_sga_decoder = {
> + .name = "sga",
> + .long_name = NULL_IF_CONFIG_SMALL("Digital Pictures SGA Video"),
> + .type = AVMEDIA_TYPE_VIDEO,
> + .id = AV_CODEC_ID_SGA_VIDEO,
> + .priv_data_size = sizeof(SGAVideoContext),
> + .init = sga_decode_init,
> + .decode = sga_decode_frame,
> + .close = sga_decode_end,
> + .capabilities = AV_CODEC_CAP_DR1,
> + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
> +};
>
More information about the ffmpeg-devel
mailing list