Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
On Wed, 22 Aug 2018 at 17:01, 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/prosumer.c | 405 > libavformat/riff.c | 1 + > 6 files changed, 416 insertions(+) > create mode 100644 libavcodec/prosumer.c > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index f0c8226283..9a309c348e 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -515,6 +515,7 @@ OBJS-$(CONFIG_PRORES_DECODER) += proresdec2.o > proresdsp.o proresdata.o > OBJS-$(CONFIG_PRORES_ENCODER) += proresenc_anatoliy.o > OBJS-$(CONFIG_PRORES_AW_ENCODER) += proresenc_anatoliy.o > OBJS-$(CONFIG_PRORES_KS_ENCODER) += proresenc_kostya.o proresdata.o > +OBJS-$(CONFIG_PROSUMER_DECODER)+= prosumer.o > OBJS-$(CONFIG_PSD_DECODER) += psd.o > OBJS-$(CONFIG_PTX_DECODER) += ptx.o > OBJS-$(CONFIG_QCELP_DECODER) += qcelpdec.o \ > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > index fd35fc1d0b..b1d1ef26c0 100644 > --- a/libavcodec/allcodecs.c > +++ b/libavcodec/allcodecs.c > @@ -235,6 +235,7 @@ extern AVCodec ff_prores_encoder; > extern AVCodec ff_prores_decoder; > extern AVCodec ff_prores_aw_encoder; > extern AVCodec ff_prores_ks_encoder; > +extern AVCodec ff_prosumer_decoder; > extern AVCodec ff_psd_decoder; > extern AVCodec ff_ptx_decoder; > extern AVCodec ff_qdraw_decoder; > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > index 31e50d5a94..2a4be2ca4f 100644 > --- a/libavcodec/avcodec.h > +++ b/libavcodec/avcodec.h > @@ -448,6 +448,7 @@ enum AVCodecID { > AV_CODEC_ID_GDV, > AV_CODEC_ID_FITS, > AV_CODEC_ID_IMM4, > +AV_CODEC_ID_PROSUMER, > > /* 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 af66b35d2b..e611183599 100644 > --- a/libavcodec/codec_desc.c > +++ b/libavcodec/codec_desc.c > @@ -1661,6 +1661,13 @@ static const AVCodecDescriptor codec_descriptors[] > = { > .long_name = NULL_IF_CONFIG_SMALL("Infinity IMM4"), > .props = AV_CODEC_PROP_LOSSY, > }, > +{ > +.id= AV_CODEC_ID_PROSUMER, > +.type = AVMEDIA_TYPE_VIDEO, > +.name = "prosumer", > +.long_name = NULL_IF_CONFIG_SMALL("Brooktree ProSumer Video"), > +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, > +}, > > /* various PCM "codecs" */ > { > diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c > new file mode 100644 > index 00..7b9d5e7bdb > --- /dev/null > +++ b/libavcodec/prosumer.c > @@ -0,0 +1,405 @@ > +/* > + * Brooktree ProSumer Video 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/imgutils.h" > +#include "libavutil/internal.h" > +#include "libavutil/intreadwrite.h" > +#include "libavutil/mem.h" > + > +#include "avcodec.h" > +#include "bytestream.h" > +#include "internal.h" > + > +typedef struct ProSumerContext { > +GetByteContext gb; > +PutByteContext pb; > + > +unsigned stride; > +unsigned size; > +unsigned lut[0x1]; > uint32_t, see below. > +uint8_t *table_b; > +uint8_t *decbuffer; > +} ProSumerContext; > + > +#define PAIR(high, low) (((uint64_t)(high)< + > +static int decompress(GetByteContext *gb, int size, PutByteContext *pb, > const unsigned *lut) > +{ > +int i, pos, idx, cnt, fill; > +unsigned a, b, c; > uint32_t, see below. + > +bytestream2_skip(gb, 32); > +cnt = 4; > +a = bytestream2_get_le32(gb); > +idx = a >> 20; > +b = lut[2 * idx]; > + > +while (1) { > This loop looks a bit lock-prone but since you check the bytestream reader status everywhere should be fine. > +if (((b & 0xFF00u) != 0x8000u) || (b & 0xFFu)) { > +if ((b & 0xFF00u) != 0x8000u) { > +
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
Will apply. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
On 8/23/18, Carl Eugen Hoyos wrote: > 2018-08-23 14:51 GMT+02:00, Paul B Mahol : >> On 8/23/18, Carl Eugen Hoyos wrote: >>> 2018-08-23 14:29 GMT+02:00, Paul B Mahol : On 8/23/18, Carl Eugen Hoyos wrote: > 2018-08-23 11:11 GMT+02:00, Paul B Mahol : >> On 8/23/18, Carl Eugen Hoyos wrote: >>> 2018-08-22 21:24 GMT+02:00, Paul B Mahol : On 8/22/18, Carl Eugen Hoyos wrote: > 2018-08-22 18:00 GMT+02:00, Paul B Mahol : > >> +switch (avctx->bits_per_coded_sample) { >> +case 12: >> + s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; >> + break; >> +default: >> + return AVERROR_INVALIDDATA; >> +} > > Why are the condition and the error needed? Because only that is supported. >>> >>> Do valid samples with other values exist? >> >> No. > > Then I suggest to make the whole block above just: > s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; Nope, bits per coded sample must be checked. >>> >>> Could you explain why? >> >> Reference decoder checks it, so do we. > > Shouldn't we try to decode files if at all possible? Nope. > >>> Am I correct that no other decoder does that? >> >> Nope. > > Which decoder does it? > Utvideo, magicyuv, y41p... ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
2018-08-23 14:51 GMT+02:00, Paul B Mahol : > On 8/23/18, Carl Eugen Hoyos wrote: >> 2018-08-23 14:29 GMT+02:00, Paul B Mahol : >>> On 8/23/18, Carl Eugen Hoyos wrote: 2018-08-23 11:11 GMT+02:00, Paul B Mahol : > On 8/23/18, Carl Eugen Hoyos wrote: >> 2018-08-22 21:24 GMT+02:00, Paul B Mahol : >>> On 8/22/18, Carl Eugen Hoyos wrote: 2018-08-22 18:00 GMT+02:00, Paul B Mahol : > +switch (avctx->bits_per_coded_sample) { > +case 12: > + s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; > + break; > +default: > + return AVERROR_INVALIDDATA; > +} Why are the condition and the error needed? >>> >>> Because only that is supported. >> >> Do valid samples with other values exist? > > No. Then I suggest to make the whole block above just: s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; >>> >>> Nope, bits per coded sample must be checked. >> >> Could you explain why? > > Reference decoder checks it, so do we. Shouldn't we try to decode files if at all possible? >> Am I correct that no other decoder does that? > > Nope. Which decoder does it? Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
On 8/23/18, Carl Eugen Hoyos wrote: > 2018-08-23 14:29 GMT+02:00, Paul B Mahol : >> On 8/23/18, Carl Eugen Hoyos wrote: >>> 2018-08-23 11:11 GMT+02:00, Paul B Mahol : On 8/23/18, Carl Eugen Hoyos wrote: > 2018-08-22 21:24 GMT+02:00, Paul B Mahol : >> On 8/22/18, Carl Eugen Hoyos wrote: >>> 2018-08-22 18:00 GMT+02:00, Paul B Mahol : >>> +switch (avctx->bits_per_coded_sample) { +case 12: + s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; + break; +default: + return AVERROR_INVALIDDATA; +} >>> >>> Why are the condition and the error needed? >> >> Because only that is supported. > > Do valid samples with other values exist? No. >>> >>> Then I suggest to make the whole block above just: >>> s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; >> >> Nope, bits per coded sample must be checked. > > Could you explain why? Reference decoder checks it, so do we. > > Am I correct that no other decoder does that? Nope. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
2018-08-23 14:29 GMT+02:00, Paul B Mahol : > On 8/23/18, Carl Eugen Hoyos wrote: >> 2018-08-23 11:11 GMT+02:00, Paul B Mahol : >>> On 8/23/18, Carl Eugen Hoyos wrote: 2018-08-22 21:24 GMT+02:00, Paul B Mahol : > On 8/22/18, Carl Eugen Hoyos wrote: >> 2018-08-22 18:00 GMT+02:00, Paul B Mahol : >> >>> +switch (avctx->bits_per_coded_sample) { >>> +case 12: >>> + s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; >>> + break; >>> +default: >>> + return AVERROR_INVALIDDATA; >>> +} >> >> Why are the condition and the error needed? > > Because only that is supported. Do valid samples with other values exist? >>> >>> No. >> >> Then I suggest to make the whole block above just: >> s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; > > Nope, bits per coded sample must be checked. Could you explain why? Am I correct that no other decoder does that? Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
On 8/23/18, Carl Eugen Hoyos wrote: > 2018-08-23 11:11 GMT+02:00, Paul B Mahol : >> On 8/23/18, Carl Eugen Hoyos wrote: >>> 2018-08-22 21:24 GMT+02:00, Paul B Mahol : On 8/22/18, Carl Eugen Hoyos wrote: > 2018-08-22 18:00 GMT+02:00, Paul B Mahol : > >> +switch (avctx->bits_per_coded_sample) { >> +case 12: >> + s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; >> + break; >> +default: >> + return AVERROR_INVALIDDATA; >> +} > > Why are the condition and the error needed? Because only that is supported. >>> >>> Do valid samples with other values exist? >> >> No. > > Then I suggest to make the whole block above just: > s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; Nope, bits per coded sample must be checked. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
2018-08-23 11:11 GMT+02:00, Paul B Mahol : > On 8/23/18, Carl Eugen Hoyos wrote: >> 2018-08-22 21:24 GMT+02:00, Paul B Mahol : >>> On 8/22/18, Carl Eugen Hoyos wrote: 2018-08-22 18:00 GMT+02:00, Paul B Mahol : > +switch (avctx->bits_per_coded_sample) { > +case 12: > + s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; > + break; > +default: > + return AVERROR_INVALIDDATA; > +} Why are the condition and the error needed? >>> >>> Because only that is supported. >> >> Do valid samples with other values exist? > > No. Then I suggest to make the whole block above just: s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
On 8/23/18, Michael Niedermayer wrote: > On Wed, Aug 22, 2018 at 06:00:54PM +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/prosumer.c | 405 >> libavformat/riff.c | 1 + >> 6 files changed, 416 insertions(+) >> create mode 100644 libavcodec/prosumer.c >> [...] >> +} >> +pos = bytestream2_tell(gb) ^ 2; >> +bytestream2_seek(gb, pos, SEEK_SET); >> +AV_WN16(&a, bytestream2_peek_le16(gb)); >> +pos = pos ^ 2; >> +bytestream2_seek(gb, pos, SEEK_SET); >> +bytestream2_skip(gb, 2); >> +cnt = 4; >> +idx--; >> +} > >> +b = PAIR(4, a) >> 16; > > I think this assumes sizeof(int) == 4, this is not guranteed it could be 8 Fixed locally. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
On Wed, Aug 22, 2018 at 06:00:54PM +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/prosumer.c | 405 > libavformat/riff.c | 1 + > 6 files changed, 416 insertions(+) > create mode 100644 libavcodec/prosumer.c > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index f0c8226283..9a309c348e 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -515,6 +515,7 @@ OBJS-$(CONFIG_PRORES_DECODER) += proresdec2.o > proresdsp.o proresdata.o > OBJS-$(CONFIG_PRORES_ENCODER) += proresenc_anatoliy.o > OBJS-$(CONFIG_PRORES_AW_ENCODER) += proresenc_anatoliy.o > OBJS-$(CONFIG_PRORES_KS_ENCODER) += proresenc_kostya.o proresdata.o > +OBJS-$(CONFIG_PROSUMER_DECODER)+= prosumer.o > OBJS-$(CONFIG_PSD_DECODER) += psd.o > OBJS-$(CONFIG_PTX_DECODER) += ptx.o > OBJS-$(CONFIG_QCELP_DECODER) += qcelpdec.o \ > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > index fd35fc1d0b..b1d1ef26c0 100644 > --- a/libavcodec/allcodecs.c > +++ b/libavcodec/allcodecs.c > @@ -235,6 +235,7 @@ extern AVCodec ff_prores_encoder; > extern AVCodec ff_prores_decoder; > extern AVCodec ff_prores_aw_encoder; > extern AVCodec ff_prores_ks_encoder; > +extern AVCodec ff_prosumer_decoder; > extern AVCodec ff_psd_decoder; > extern AVCodec ff_ptx_decoder; > extern AVCodec ff_qdraw_decoder; > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > index 31e50d5a94..2a4be2ca4f 100644 > --- a/libavcodec/avcodec.h > +++ b/libavcodec/avcodec.h > @@ -448,6 +448,7 @@ enum AVCodecID { > AV_CODEC_ID_GDV, > AV_CODEC_ID_FITS, > AV_CODEC_ID_IMM4, > +AV_CODEC_ID_PROSUMER, > > /* 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 af66b35d2b..e611183599 100644 > --- a/libavcodec/codec_desc.c > +++ b/libavcodec/codec_desc.c > @@ -1661,6 +1661,13 @@ static const AVCodecDescriptor codec_descriptors[] = { > .long_name = NULL_IF_CONFIG_SMALL("Infinity IMM4"), > .props = AV_CODEC_PROP_LOSSY, > }, > +{ > +.id= AV_CODEC_ID_PROSUMER, > +.type = AVMEDIA_TYPE_VIDEO, > +.name = "prosumer", > +.long_name = NULL_IF_CONFIG_SMALL("Brooktree ProSumer Video"), > +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, > +}, > > /* various PCM "codecs" */ > { > diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c > new file mode 100644 > index 00..7b9d5e7bdb > --- /dev/null > +++ b/libavcodec/prosumer.c > @@ -0,0 +1,405 @@ > +/* > + * Brooktree ProSumer Video 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/imgutils.h" > +#include "libavutil/internal.h" > +#include "libavutil/intreadwrite.h" > +#include "libavutil/mem.h" > + > +#include "avcodec.h" > +#include "bytestream.h" > +#include "internal.h" > + > +typedef struct ProSumerContext { > +GetByteContext gb; > +PutByteContext pb; > + > +unsigned stride; > +unsigned size; > +unsigned lut[0x1]; > +uint8_t *table_b; > +uint8_t *decbuffer; > +} ProSumerContext; > + > +#define PAIR(high, low) (((uint64_t)(high)< + > +static int decompress(GetByteContext *gb, int size, PutByteContext *pb, > const unsigned *lut) > +{ > +int i, pos, idx, cnt, fill; > +unsigned a, b, c; > + > +bytestream2_skip(gb, 32); > +cnt = 4; > +a = bytestream2_get_le32(gb); > +idx = a >> 20; > +b = lut[2 * idx]; > + > +while (1) { > +if (((b & 0xFF00u) != 0x8000u) || (b & 0xFFu)) { > +if ((b & 0xFF00u) != 0x8000u) { > +bytestream2_put_le16(pb, b); > +} else if (b & 0xFFu) { > +idx = 0; > +for (i = 0; i < (b & 0xFFu); i++)
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
On 8/23/18, Carl Eugen Hoyos wrote: > 2018-08-22 21:24 GMT+02:00, Paul B Mahol : >> On 8/22/18, Carl Eugen Hoyos wrote: >>> 2018-08-22 18:00 GMT+02:00, Paul B Mahol : >>> +switch (avctx->bits_per_coded_sample) { +case 12: + s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; + break; +default: + return AVERROR_INVALIDDATA; +} >>> >>> Why are the condition and the error needed? >> >> Because only that is supported. > > Do valid samples with other values exist? No. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
2018-08-22 21:24 GMT+02:00, Paul B Mahol : > On 8/22/18, Carl Eugen Hoyos wrote: >> 2018-08-22 18:00 GMT+02:00, Paul B Mahol : >> >>> +switch (avctx->bits_per_coded_sample) { >>> +case 12: >>> + s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; >>> + break; >>> +default: >>> + return AVERROR_INVALIDDATA; >>> +} >> >> Why are the condition and the error needed? > > Because only that is supported. Do valid samples with other values exist? Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
On 8/22/18, Carl Eugen Hoyos wrote: > 2018-08-22 18:00 GMT+02:00, Paul B Mahol : > >> +switch (avctx->bits_per_coded_sample) { >> +case 12: >> + s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; >> + break; >> +default: >> + return AVERROR_INVALIDDATA; >> +} > > Why are the condition and the error needed? Because only that is supported. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
2018-08-22 18:00 GMT+02:00, Paul B Mahol : > +switch (avctx->bits_per_coded_sample) { > +case 12: > + s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; > + break; > +default: > + return AVERROR_INVALIDDATA; > +} Why are the condition and the error needed? Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 7 + libavcodec/prosumer.c | 405 libavformat/riff.c | 1 + 6 files changed, 416 insertions(+) create mode 100644 libavcodec/prosumer.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index f0c8226283..9a309c348e 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -515,6 +515,7 @@ OBJS-$(CONFIG_PRORES_DECODER) += proresdec2.o proresdsp.o proresdata.o OBJS-$(CONFIG_PRORES_ENCODER) += proresenc_anatoliy.o OBJS-$(CONFIG_PRORES_AW_ENCODER) += proresenc_anatoliy.o OBJS-$(CONFIG_PRORES_KS_ENCODER) += proresenc_kostya.o proresdata.o +OBJS-$(CONFIG_PROSUMER_DECODER)+= prosumer.o OBJS-$(CONFIG_PSD_DECODER) += psd.o OBJS-$(CONFIG_PTX_DECODER) += ptx.o OBJS-$(CONFIG_QCELP_DECODER) += qcelpdec.o \ diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index fd35fc1d0b..b1d1ef26c0 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -235,6 +235,7 @@ extern AVCodec ff_prores_encoder; extern AVCodec ff_prores_decoder; extern AVCodec ff_prores_aw_encoder; extern AVCodec ff_prores_ks_encoder; +extern AVCodec ff_prosumer_decoder; extern AVCodec ff_psd_decoder; extern AVCodec ff_ptx_decoder; extern AVCodec ff_qdraw_decoder; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 31e50d5a94..2a4be2ca4f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -448,6 +448,7 @@ enum AVCodecID { AV_CODEC_ID_GDV, AV_CODEC_ID_FITS, AV_CODEC_ID_IMM4, +AV_CODEC_ID_PROSUMER, /* 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 af66b35d2b..e611183599 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1661,6 +1661,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Infinity IMM4"), .props = AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_PROSUMER, +.type = AVMEDIA_TYPE_VIDEO, +.name = "prosumer", +.long_name = NULL_IF_CONFIG_SMALL("Brooktree ProSumer Video"), +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, +}, /* various PCM "codecs" */ { diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c new file mode 100644 index 00..7b9d5e7bdb --- /dev/null +++ b/libavcodec/prosumer.c @@ -0,0 +1,405 @@ +/* + * Brooktree ProSumer Video 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/imgutils.h" +#include "libavutil/internal.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" + +#include "avcodec.h" +#include "bytestream.h" +#include "internal.h" + +typedef struct ProSumerContext { +GetByteContext gb; +PutByteContext pb; + +unsigned stride; +unsigned size; +unsigned lut[0x1]; +uint8_t *table_b; +uint8_t *decbuffer; +} ProSumerContext; + +#define PAIR(high, low) (((uint64_t)(high)<> 20; +b = lut[2 * idx]; + +while (1) { +if (((b & 0xFF00u) != 0x8000u) || (b & 0xFFu)) { +if ((b & 0xFF00u) != 0x8000u) { +bytestream2_put_le16(pb, b); +} else if (b & 0xFFu) { +idx = 0; +for (i = 0; i < (b & 0xFFu); i++) +bytestream2_put_le32(pb, 0); +} +c = b >> 16; +if (c & 0xFF00u) { +c = (((c >> 8) & 0xFFu) | (c & 0xFF00)) & 0xF00F; +fill = lut[2 * idx + 1]; +if ((c & 0xFF00u) == 0x1000) { +bytestream2_put_le16(pb, fill); +c &= 0x00FFu; +} else { +bytestream2_put_le32(pb, fill); +c &= 0x00FFu; +} +} +while (c) { +a <<= 4; +cn