[FFmpeg-devel] [PATCH 2/3] avcodec: add SGA Video decoder

Paul B Mahol onemda at gmail.com
Sat Feb 27 14:18:11 EET 2021


On Sat, Feb 27, 2021 at 4:19 AM James Almer <jamrial at gmail.com> wrote:

> 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?
>

Nope.


>
> [...]
>
> > +    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?
>

Nope, codec have support for inter frames, just not implemented yet.

>
> > +    frame->key_frame = 1;
>
> The demuxer does not seem to set every packet as key frame, only some.


That is for working seeking, if you have not noticed there are not pure
chunks but chunks muxed
in sectors of 2048 bytes.



>
> 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,
> > +};
> >
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list