[FFmpeg-cvslog] r24873 - in trunk/libavcodec: a64enc.h a64multienc.c a64tables.h

Stefano Sabatini stefano.sabatini-lala
Mon Aug 23 16:08:01 CEST 2010


On date Monday 2010-08-23 13:46:33 +0200, bindhammer wrote:
> Author: bindhammer
> Date: Mon Aug 23 13:46:32 2010
> New Revision: 24873
> 
> Log:
> Initial version of the a64 (multicolor charset) codec
> 
> Added:
>    trunk/libavcodec/a64enc.h
>    trunk/libavcodec/a64multienc.c
>    trunk/libavcodec/a64tables.h
> 
> Added: trunk/libavcodec/a64enc.h
> ==============================================================================
> --- /dev/null	00:00:00 1970	(empty, because file is newly added)
> +++ trunk/libavcodec/a64enc.h	Mon Aug 23 13:46:32 2010	(r24873)
> @@ -0,0 +1,50 @@
> +/*
> + * a64 video encoder - basic headers
> + * Copyright (c) 2009 Tobias Bindhammer
> + *
> + * 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
> + * a64 video encoder - basic headers
> + */
> +
> +#ifndef AVCODEC_A64ENC_H
> +#define AVCODEC_A64ENC_H
> +
> +#include "libavutil/lfg.h"
> +#include "avcodec.h"
> +
> +#define C64XRES 320
> +#define C64YRES 200
> +
> +typedef struct A64Context {
> +    /* general variables */
> +    AVFrame picture;
> +
> +    /* variables for multicolor modes */
> +    AVLFG randctx;
> +    int mc_lifetime;
> +    int mc_use_5col;
> +    int mc_frame_counter;
> +    int *mc_meta_charset;
> +    int *mc_charmap;
> +    int *mc_best_cb;
> +} A64Context;
> +
> +#endif /* AVCODEC_A64ENC_H */
> 
> Added: trunk/libavcodec/a64multienc.c
> ==============================================================================
> --- /dev/null	00:00:00 1970	(empty, because file is newly added)
> +++ trunk/libavcodec/a64multienc.c	Mon Aug 23 13:46:32 2010	(r24873)
> @@ -0,0 +1,248 @@
> +/*
> + * a64 video encoder - multicolor modes
> + * Copyright (c) 2009 Tobias Bindhammer
> + *
> + * 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
> + * a64 video encoder - multicolor modes
> + */
> +
> +#include "a64enc.h"
> +#include "a64tables.h"
> +#include "elbg.h"
> +#include "libavutil/intreadwrite.h"
> +
> +#define DITHERSTEPS 8
> +
[...]
> +static int a64multi_encode_frame(AVCodecContext *avctx, unsigned char *buf,
> +                                 int buf_size, void *data)
> +{
> +    A64Context *c = avctx->priv_data;
> +    AVFrame *pict = data;
> +    AVFrame *const p = (AVFrame *) & c->picture;
> +
> +    int frame;
> +    int a;
> +
> +    uint8_t colrammap[256];
> +    int *charmap = c->mc_charmap;
> +    int *meta    = c->mc_meta_charset;
> +    int *best_cb = c->mc_best_cb;
> +    int frm_size = 0x400 + 0x400 * c->mc_use_5col;
> +    int req_size;
> +
> +    /* it is the last frame so prepare to flush */
> +    if (!data)
> +        c->mc_lifetime = c->mc_frame_counter;
> +
> +    req_size = 0x800 + frm_size * c->mc_lifetime;
> +
> +    if (req_size > buf_size) {
> +        av_log(avctx, AV_LOG_ERROR, "buf size too small (need %d, got %d)\n", req_size, buf_size);
> +        return -1;

AVERROR(EINVAL);

[...]
> +AVCodec a64multi_encoder = {
> +    .name           = "a64multi",
> +    .type           = CODEC_TYPE_VIDEO,

CODEC_TYPE_VIDEO is deprecated, use AVMEDIA_TYPE_VIDEO instead, same
below.

> +    .id             = CODEC_ID_A64_MULTI,
> +    .priv_data_size = sizeof(A64Context),
> +    .init           = a64multi_init_encoder,
> +    .encode         = a64multi_encode_frame,
> +    .close          = a64multi_close_encoder,
> +    .pix_fmts       = (enum PixelFormat[]) {PIX_FMT_GRAY8, PIX_FMT_NONE},
> +    .long_name      = NULL_IF_CONFIG_SMALL("Multicolor charset for Commodore 64"),
> +    .capabilities   = CODEC_CAP_DELAY,
> +};
> +
> +AVCodec a64multi5_encoder = {
> +    .name           = "a64multi5",
> +    .type           = CODEC_TYPE_VIDEO,
> +    .id             = CODEC_ID_A64_MULTI5,
> +    .priv_data_size = sizeof(A64Context),
> +    .init           = a64multi_init_encoder,
> +    .encode         = a64multi_encode_frame,
> +    .close          = a64multi_close_encoder,
> +    .pix_fmts       = (enum PixelFormat[]) {PIX_FMT_GRAY8, PIX_FMT_NONE},
> +    .long_name      = NULL_IF_CONFIG_SMALL("Multicolor charset for Commodore 64, extended with 5th color (colram)"),
> +    .capabilities   = CODEC_CAP_DELAY,
> +};

BTW welcome aboard! :)



More information about the ffmpeg-cvslog mailing list