35 #define CDG_FULL_WIDTH 300 36 #define CDG_FULL_HEIGHT 216 37 #define CDG_DISPLAY_WIDTH 294 38 #define CDG_DISPLAY_HEIGHT 204 39 #define CDG_BORDER_WIDTH 6 40 #define CDG_BORDER_HEIGHT 12 43 #define CDG_COMMAND 0x09 47 #define CDG_INST_MEMORY_PRESET 1 48 #define CDG_INST_BORDER_PRESET 2 49 #define CDG_INST_TILE_BLOCK 6 50 #define CDG_INST_SCROLL_PRESET 20 51 #define CDG_INST_SCROLL_COPY 24 52 #define CDG_INST_TRANSPARENT_COL 28 53 #define CDG_INST_LOAD_PAL_LO 30 54 #define CDG_INST_LOAD_PAL_HIGH 31 55 #define CDG_INST_TILE_BLOCK_XOR 38 58 #define CDG_PACKET_SIZE 24 59 #define CDG_DATA_SIZE 16 60 #define CDG_TILE_HEIGHT 12 61 #define CDG_TILE_WIDTH 6 62 #define CDG_MINIMUM_PKT_SIZE 6 63 #define CDG_MINIMUM_SCROLL_SIZE 3 64 #define CDG_HEADER_SIZE 8 65 #define CDG_PALETTE_SIZE 16 93 int color = data[0] & 0x0F;
95 if (!(data[1] & 0x0F)) {
115 int array_offset = low ? 0 : 8;
116 uint32_t *palette = (uint32_t *) cc->
frame->
data[1];
118 for (i = 0; i < 8; i++) {
119 color = (data[2 *
i] << 6) + (data[2 * i + 1] & 0x3F);
120 r = ((color >> 8) & 0x000F) * 17;
121 g = ((color >> 4) & 0x000F) * 17;
122 b = ((
color ) & 0x000F) * 17;
123 palette[i + array_offset] = 0xFF
U << 24 | r << 16 | g << 8 |
b;
149 if (!((data[4 + y] >> (5 - x)) & 0x01))
150 color = data[0] & 0x0F;
152 color = data[1] & 0x0F;
154 ai = ci + x + (stride * (ri + y));
175 in += in_tl_x + in_tl_y *
stride;
176 out += out_tl_x + out_tl_y *
stride;
177 for (y = 0; y <
h; y++)
178 memcpy(out + y * stride, in + y * stride, w);
186 for (y = tl_y; y < tl_y +
h; y++)
187 memset(out + tl_x + y * stride, color, w);
203 AVFrame *new_frame,
int roll_over)
206 int hscmd, h_off, hinc, vscmd, v_off, vinc;
212 color = data[0] & 0x0F;
213 hscmd = (data[1] & 0x30) >> 4;
214 vscmd = (data[2] & 0x30) >> 4;
240 memcpy(out +
FFMAX(0, hinc) + stride * y,
241 in +
FFMAX(0, hinc) - hinc + (y - vinc) * stride,
242 FFMIN(stride + hinc, stride));
247 stride, vinc, stride, roll_over);
251 stride, -1 * vinc, stride, roll_over);
268 int buf_size = avpkt->
size;
294 command = bytestream2_get_byte(&gb);
295 inst = bytestream2_get_byte(&gb);
303 if (!(cdg_data[1] & 0x0F))
304 memset(cc->
frame->
data[0], cdg_data[0] & 0x0F,
355 if (!frame->
data[0]) {
390 .
name =
"cdgraphics",
#define CDG_BORDER_HEIGHT
This structure describes decoded (raw) audio or video data.
#define CDG_INST_TRANSPARENT_COL
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
static av_cold int init(AVCodecContext *avctx)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static void cdg_border_preset(CDGraphicsContext *cc, uint8_t *data)
#define CDG_INST_LOAD_PAL_HIGH
#define CDG_INST_SCROLL_PRESET
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static void cdg_fill_wrapper(int out_tl_x, int out_tl_y, uint8_t *out, int in_tl_x, int in_tl_y, uint8_t *in, int color, int w, int h, int stride, int roll)
static int cdg_tile_block(CDGraphicsContext *cc, uint8_t *data, int b)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static void cdg_copy_rect_buf(int out_tl_x, int out_tl_y, uint8_t *out, int in_tl_x, int in_tl_y, uint8_t *in, int w, int h, int stride)
8 bits with AV_PIX_FMT_RGB32 palette
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold int cdg_decode_init(AVCodecContext *avctx)
#define CDG_MINIMUM_PKT_SIZE
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static void cdg_fill_rect_preset(int tl_x, int tl_y, uint8_t *out, int color, int w, int h, int stride)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available...
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
#define CDG_INST_BORDER_PRESET
static av_cold int cdg_decode_end(AVCodecContext *avctx)
#define CDG_INST_TILE_BLOCK
const char * name
Name of the codec implementation.
#define CDG_FULL_WIDTH
default screen sizes
static int cdg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define CDG_INST_MEMORY_PRESET
instruction codes
static void cdg_decode_flush(AVCodecContext *avctx)
static void cdg_scroll(CDGraphicsContext *cc, uint8_t *data, AVFrame *new_frame, int roll_over)
static void cdg_load_palette(CDGraphicsContext *cc, uint8_t *data, int low)
Libavcodec external API header.
AVCodec ff_cdgraphics_decoder
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
#define CDG_INST_LOAD_PAL_LO
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);return NULL;}return ac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
int palette_has_changed
Tell user application that palette has changed from previous frame.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define CDG_INST_TILE_BLOCK_XOR
GLint GLenum GLboolean GLsizei stride
common internal api header.
int frame_number
Frame counter, set by libavcodec.
#define CDG_INST_SCROLL_COPY
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
This structure stores compressed data.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define CDG_MINIMUM_SCROLL_SIZE