[FFmpeg-devel] [PATCH] avcodec: add PhotoCD decoder
Paul B Mahol
onemda at gmail.com
Sat Aug 29 23:41:25 EEST 2020
On 8/29/20, Paul B Mahol <onemda at gmail.com> wrote:
> Signed-Goff-by: Paul B Mahol <onemda at gmail.com>
> ---
> Probably need to be applied on top of moflex v2 patch set.
> ---
[...]
> +
> +static av_cold int photocd_decode_init(AVCodecContext *avctx)
> +{
> + avctx->pix_fmt = AV_PIX_FMT_YUV420P;
> + avctx->colorspace = AVCOL_SPC_BT709;
> + avctx->color_primaries = AVCOL_PRI_BT709;
> + avctx->color_trc = AVCOL_TRC_IEC61966_2_4;
> + avctx->color_range = AVCOL_RANGE_MPEG;
Locally changed to JPEG color range, as that is much better looking.
> +
> + return 0;
> +}
> +
> +static av_cold int photocd_decode_close(AVCodecContext *avctx)
> +{
> + PhotoCDContext *s = avctx->priv_data;
> +
> + for (int i = 0; i < 3; i++)
> + ff_free_vlc(&s->vlc[i]);
> +
> + return 0;
> +}
> +
> +#define OFFSET(x) offsetof(PhotoCDContext, x)
> +#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
> +
> +static const AVOption options[] = {
> + { "lowres", "Lower the decoding resolution by a power of two",
> + OFFSET(lowres), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 4, VD },
> + { NULL },
> +};
> +
> +static const AVClass photocd_class = {
> + .class_name = "photocd",
> + .item_name = av_default_item_name,
> + .option = options,
> + .version = LIBAVUTIL_VERSION_INT,
> +};
> +
> +AVCodec ff_photocd_decoder = {
> + .name = "photocd",
> + .type = AVMEDIA_TYPE_VIDEO,
> + .id = AV_CODEC_ID_PHOTOCD,
> + .priv_data_size = sizeof (PhotoCDContext),
> + .priv_class = &photocd_class,
> + .init = photocd_decode_init,
> + .close = photocd_decode_close,
> + .decode = photocd_decode_frame,
> + .capabilities = AV_CODEC_CAP_DR1,
> + .long_name = NULL_IF_CONFIG_SMALL("Kodak Photo CD"),
> +};
> diff --git a/libavformat/img2.c b/libavformat/img2.c
> index d243d6c125..db37aa7228 100644
> --- a/libavformat/img2.c
> +++ b/libavformat/img2.c
> @@ -55,6 +55,7 @@ const IdStrMap ff_img_tags[] = {
> { AV_CODEC_ID_TIFF, "dng" },
> { AV_CODEC_ID_SGI, "sgi" },
> { AV_CODEC_ID_PTX, "ptx" },
> + { AV_CODEC_ID_PHOTOCD, "pcd" },
> { AV_CODEC_ID_PCX, "pcx" },
> { AV_CODEC_ID_QDRAW, "pic" },
> { AV_CODEC_ID_QDRAW, "pct" },
> --
> 2.17.1
>
>
More information about the ffmpeg-devel
mailing list