Re: [FFmpeg-devel] [PATCH] avcodec: add Cintel RAW decoder
On Wed, Oct 07, 2020 at 02:16:05PM +0100, Kieran O Leary wrote: > Woah, this is unexpected and amazing. Which versions of Cintel RAW does > this support? If I recall correctly, there's a lossy mode, lossless > compression mode and maybe originally it was uncompressed raw? It supports all compression modes and also both uncompressed raw modes. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec: add Cintel RAW decoder
Woah, this is unexpected and amazing. Which versions of Cintel RAW does this support? If I recall correctly, there's a lossy mode, lossless compression mode and maybe originally it was uncompressed raw? Best, Kieran O'Leary National Library of Ireland ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec: add Cintel RAW decoder
On Thu, Oct 01, 2020 at 07:20:29PM +0200, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > libavcodec/Makefile | 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/codec_desc.c | 7 + > libavcodec/codec_id.h | 1 + > libavcodec/cri.c| 300 > libavformat/img2.c | 1 + > 6 files changed, 311 insertions(+) > create mode 100644 libavcodec/cri.c > will apply soon. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec: add Cintel RAW decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 + libavcodec/codec_id.h | 1 + libavcodec/cri.c| 328 libavformat/img2.c | 1 + 6 files changed, 339 insertions(+) create mode 100644 libavcodec/cri.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 816d87ba60..488cb158ef 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -269,6 +269,7 @@ OBJS-$(CONFIG_COMFORTNOISE_DECODER)+= cngdec.o celp_filters.o OBJS-$(CONFIG_COMFORTNOISE_ENCODER)+= cngenc.o OBJS-$(CONFIG_COOK_DECODER)+= cook.o OBJS-$(CONFIG_CPIA_DECODER)+= cpia.o +OBJS-$(CONFIG_CRI_DECODER) += cri.o OBJS-$(CONFIG_CSCD_DECODER)+= cscd.o OBJS-$(CONFIG_CYUV_DECODER)+= cyuv.o OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o \ diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 2b580b66cf..52fc415815 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -82,6 +82,7 @@ extern AVCodec ff_cllc_decoder; extern AVCodec ff_comfortnoise_encoder; extern AVCodec ff_comfortnoise_decoder; extern AVCodec ff_cpia_decoder; +extern AVCodec ff_cri_decoder; extern AVCodec ff_cscd_decoder; extern AVCodec ff_cyuv_decoder; extern AVCodec ff_dds_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 1246dc2b96..01c0eca7b4 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1812,6 +1812,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Argonaut Games Video"), .props = AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_CRI, +.type = AVMEDIA_TYPE_VIDEO, +.name = "cri", +.long_name = NULL_IF_CONFIG_SMALL("Cintel RAW"), +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS, +}, /* various PCM "codecs" */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 21444f9ce3..e933f7664a 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -300,6 +300,7 @@ enum AVCodecID { AV_CODEC_ID_PHOTOCD, AV_CODEC_ID_IPU, AV_CODEC_ID_ARGO, +AV_CODEC_ID_CRI, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/cri.c b/libavcodec/cri.c new file mode 100644 index 00..8b31fdbfae --- /dev/null +++ b/libavcodec/cri.c @@ -0,0 +1,328 @@ +/* + * CRI image decoder + * + * Copyright (c) 2020 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 + */ + +/** + * @file + * Cintel RAW image decoder + */ + +#define BITSTREAM_READER_LE + +#include "libavutil/intfloat.h" +#include "libavutil/display.h" +#include "avcodec.h" +#include "bytestream.h" +#include "get_bits.h" +#include "internal.h" +#include "thread.h" + +typedef struct CRIContext { +AVCodecContext *jpeg_avctx; // wrapper context for MJPEG +AVFrame *jpgframe;// decoded JPEG tile + +GetByteContext gb; +int color_model; +const uint8_t *data; +unsigned data_size; +uint64_t tile_size[4]; +} CRIContext; + +static av_cold int cri_decode_init(AVCodecContext *avctx) +{ +CRIContext *s = avctx->priv_data; +const AVCodec *codec; +int ret; + +s->jpgframe = av_frame_alloc(); +if (!s->jpgframe) +return AVERROR(ENOMEM); + +codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG); +if (!codec) +return AVERROR_BUG; +s->jpeg_avctx = avcodec_alloc_context3(codec); +if (!s->jpeg_avctx) +return AVERROR(ENOMEM); +s->jpeg_avctx->flags = avctx->flags; +s->jpeg_avctx->flags2 = avctx->flags2; +s->jpeg_avctx->dct_algo = avctx->dct_algo; +s->jpeg_avctx->idct_algo = avctx->idct_algo; +ret = ff_codec_open2_recursive(s->jpeg_avctx, codec, NULL); +if (ret < 0) +return ret; + +return 0; +} + +static int cri_decode_frame(AVCodecContext *avctx, void *data, +int *got_frame, AVPacket *avpkt) +{ +CRIContext *s = avctx->priv_data; +GetByteContext
Re: [FFmpeg-devel] [PATCH] avcodec: add Cintel RAW decoder
Paul B Mahol: > Signed-off-by: Paul B Mahol > --- > libavcodec/Makefile | 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/codec_desc.c | 7 + > libavcodec/codec_id.h | 1 + > libavcodec/cri.c| 300 > libavformat/img2.c | 1 + > 6 files changed, 311 insertions(+) > create mode 100644 libavcodec/cri.c > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 816d87ba60..488cb158ef 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -269,6 +269,7 @@ OBJS-$(CONFIG_COMFORTNOISE_DECODER)+= cngdec.o > celp_filters.o > OBJS-$(CONFIG_COMFORTNOISE_ENCODER)+= cngenc.o > OBJS-$(CONFIG_COOK_DECODER)+= cook.o > OBJS-$(CONFIG_CPIA_DECODER)+= cpia.o > +OBJS-$(CONFIG_CRI_DECODER) += cri.o > OBJS-$(CONFIG_CSCD_DECODER)+= cscd.o > OBJS-$(CONFIG_CYUV_DECODER)+= cyuv.o > OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o > \ > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > index 2b580b66cf..52fc415815 100644 > --- a/libavcodec/allcodecs.c > +++ b/libavcodec/allcodecs.c > @@ -82,6 +82,7 @@ extern AVCodec ff_cllc_decoder; > extern AVCodec ff_comfortnoise_encoder; > extern AVCodec ff_comfortnoise_decoder; > extern AVCodec ff_cpia_decoder; > +extern AVCodec ff_cri_decoder; > extern AVCodec ff_cscd_decoder; > extern AVCodec ff_cyuv_decoder; > extern AVCodec ff_dds_decoder; > diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c > index 1246dc2b96..01c0eca7b4 100644 > --- a/libavcodec/codec_desc.c > +++ b/libavcodec/codec_desc.c > @@ -1812,6 +1812,13 @@ static const AVCodecDescriptor codec_descriptors[] = { > .long_name = NULL_IF_CONFIG_SMALL("Argonaut Games Video"), > .props = AV_CODEC_PROP_LOSSY, > }, > +{ > +.id= AV_CODEC_ID_CRI, > +.type = AVMEDIA_TYPE_VIDEO, > +.name = "cri", > +.long_name = NULL_IF_CONFIG_SMALL("Cintel RAW"), > +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | > AV_CODEC_PROP_LOSSLESS, > +}, > > /* various PCM "codecs" */ > { > diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h > index 21444f9ce3..e933f7664a 100644 > --- a/libavcodec/codec_id.h > +++ b/libavcodec/codec_id.h > @@ -300,6 +300,7 @@ enum AVCodecID { > AV_CODEC_ID_PHOTOCD, > AV_CODEC_ID_IPU, > AV_CODEC_ID_ARGO, > +AV_CODEC_ID_CRI, > > /* various PCM "codecs" */ > AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the > start of audio codecs > diff --git a/libavcodec/cri.c b/libavcodec/cri.c > new file mode 100644 > index 00..4bd0262255 > --- /dev/null > +++ b/libavcodec/cri.c > @@ -0,0 +1,300 @@ > +/* > + * CRI image decoder > + * > + * Copyright (c) 2020 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 > + */ > + > +/** > + * @file > + * Cintel RAW image decoder > + */ > + > +#define BITSTREAM_READER_LE > + > +#include "libavutil/avassert.h" > +#include "libavutil/intreadwrite.h" > +#include "libavutil/opt.h" These three headers seem to be unnecessary. > +#include "avcodec.h" > +#include "bytestream.h" > +#include "get_bits.h" > +#include "internal.h" > +#include "thread.h" > + > +typedef struct CRIContext { > +AVCodecContext *jpeg_avctx; // wrapper context for MJPEG > +AVFrame *jpgframe;// decoded JPEG tile > + > +GetByteContext gb; > +int color_model; > +const uint8_t *data; > +unsigned data_size; > +uint64_t tile_size[4]; > +} CRIContext; > + > +static av_cold int cri_decode_init(AVCodecContext *avctx) > +{ > +CRIContext *s = avctx->priv_data; > +const AVCodec *codec; > +int ret; > + > +s->jpgframe = av_frame_alloc(); This leaks if an error happens later. > +if (!s->jpgframe) > +return AVERROR(ENOMEM); > + > +codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG); > +if (!codec) > +return AVERROR_BUG; > +s->jpeg_avctx = avcodec_alloc_context3(codec); > +if (!s->jpeg_avctx) > +return AVERROR(ENOMEM); > +s->jpeg_avctx->flags = avctx->flags; > +s->jpeg_avctx->flags2 = avctx
[FFmpeg-devel] [PATCH] avcodec: add Cintel RAW decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 + libavcodec/codec_id.h | 1 + libavcodec/cri.c| 300 libavformat/img2.c | 1 + 6 files changed, 311 insertions(+) create mode 100644 libavcodec/cri.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 816d87ba60..488cb158ef 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -269,6 +269,7 @@ OBJS-$(CONFIG_COMFORTNOISE_DECODER)+= cngdec.o celp_filters.o OBJS-$(CONFIG_COMFORTNOISE_ENCODER)+= cngenc.o OBJS-$(CONFIG_COOK_DECODER)+= cook.o OBJS-$(CONFIG_CPIA_DECODER)+= cpia.o +OBJS-$(CONFIG_CRI_DECODER) += cri.o OBJS-$(CONFIG_CSCD_DECODER)+= cscd.o OBJS-$(CONFIG_CYUV_DECODER)+= cyuv.o OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadata.o dcahuff.o \ diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 2b580b66cf..52fc415815 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -82,6 +82,7 @@ extern AVCodec ff_cllc_decoder; extern AVCodec ff_comfortnoise_encoder; extern AVCodec ff_comfortnoise_decoder; extern AVCodec ff_cpia_decoder; +extern AVCodec ff_cri_decoder; extern AVCodec ff_cscd_decoder; extern AVCodec ff_cyuv_decoder; extern AVCodec ff_dds_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 1246dc2b96..01c0eca7b4 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1812,6 +1812,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Argonaut Games Video"), .props = AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_CRI, +.type = AVMEDIA_TYPE_VIDEO, +.name = "cri", +.long_name = NULL_IF_CONFIG_SMALL("Cintel RAW"), +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_LOSSLESS, +}, /* various PCM "codecs" */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 21444f9ce3..e933f7664a 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -300,6 +300,7 @@ enum AVCodecID { AV_CODEC_ID_PHOTOCD, AV_CODEC_ID_IPU, AV_CODEC_ID_ARGO, +AV_CODEC_ID_CRI, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/cri.c b/libavcodec/cri.c new file mode 100644 index 00..4bd0262255 --- /dev/null +++ b/libavcodec/cri.c @@ -0,0 +1,300 @@ +/* + * CRI image decoder + * + * Copyright (c) 2020 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 + */ + +/** + * @file + * Cintel RAW image decoder + */ + +#define BITSTREAM_READER_LE + +#include "libavutil/avassert.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/opt.h" +#include "avcodec.h" +#include "bytestream.h" +#include "get_bits.h" +#include "internal.h" +#include "thread.h" + +typedef struct CRIContext { +AVCodecContext *jpeg_avctx; // wrapper context for MJPEG +AVFrame *jpgframe;// decoded JPEG tile + +GetByteContext gb; +int color_model; +const uint8_t *data; +unsigned data_size; +uint64_t tile_size[4]; +} CRIContext; + +static av_cold int cri_decode_init(AVCodecContext *avctx) +{ +CRIContext *s = avctx->priv_data; +const AVCodec *codec; +int ret; + +s->jpgframe = av_frame_alloc(); +if (!s->jpgframe) +return AVERROR(ENOMEM); + +codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG); +if (!codec) +return AVERROR_BUG; +s->jpeg_avctx = avcodec_alloc_context3(codec); +if (!s->jpeg_avctx) +return AVERROR(ENOMEM); +s->jpeg_avctx->flags = avctx->flags; +s->jpeg_avctx->flags2 = avctx->flags2; +s->jpeg_avctx->dct_algo = avctx->dct_algo; +s->jpeg_avctx->idct_algo = avctx->idct_algo; +ret = ff_codec_open2_recursive(s->jpeg_avctx, codec, NULL); +if (ret < 0) +return ret; + +return 0; +} + +static int cri_decode_frame(AVCodecContext *avctx, void *data, +int *got_frame, AVPacket *avpkt) +{ +CRIContext *s = avct