22 #include "libavutil/intreadwrite.h"
32 { 0, 0, 0, 0, 0, 0, 0, 0 },
33 { 2, 0, 0, 0, 0, 0, 0, 0 },
34 { 5, 7, 0, 0, 0, 0, 0, 0 },
35 { 5, 0, 0, 0, 0, 0, 0, 0 },
36 { 6, 0, 0, 0, 0, 0, 0, 0 },
37 { 5, 7, 5, 7, 0, 0, 0, 0 },
38 { 5, 7, 5, 0, 0, 0, 0, 0 },
39 { 5, 7, 6, 0, 0, 0, 0, 0 },
40 { 5, 5, 0, 0, 0, 0, 0, 0 },
41 { 3, 0, 0, 0, 0, 0, 0, 0 },
42 { 6, 6, 0, 0, 0, 0, 0, 0 },
43 { 2, 4, 0, 0, 0, 0, 0, 0 },
44 { 2, 4, 5, 7, 0, 0, 0, 0 },
45 { 2, 4, 5, 0, 0, 0, 0, 0 },
46 { 2, 4, 6, 0, 0, 0, 0, 0 },
47 { 2, 4, 5, 7, 5, 7, 0, 0 }
69 for (i = 0; i < 4; i++)
93 for (i = 0; i < 4; i++) {
109 y = ((a & 0x3F) << 1) | (b >> 7 & 1);
111 return y * 2 * avctx->
width + x * 2;
119 for (i = 0; i < 4; i++) {
129 for (i = 0; i < 4; i++) {
130 if ((mask >> 4) & (1 << (3 - i)))
132 if ((mask & 15) & (1 << (3 - i)))
141 for (i = 0; i < 4; i++) {
142 if ((mask >> 4) & (1 << (3 - i)))
144 if ((mask & 15) & (1 << (3 - i)))
145 dst[avctx->
width + i] = src[avctx->
width + i];
152 uint32_t opcode_size,
offset;
157 i = bytestream2_get_byte(&c->
gb);
167 a = bytestream2_get_byte(&c->
gb);
168 b = bytestream2_get_byte(&c->
gb);
172 offset = (b & 0x7F) * 2;
173 j = bytestream2_get_le16(&c->
gb) +
offset;
177 if (dst + 3 * avctx->
width + 4 > dend)
180 if ((offset & 0x3F) == 0)
181 dst += avctx->
width * 3;
183 }
while (offset < j);
190 a = bytestream2_get_byte(&c->
gb);
191 b = bytestream2_get_byte(&c->
gb);
195 if ((src + 3 * avctx->
width + 4 > send) ||
196 (dst + 3 * avctx->
width + 4 > dend))
201 dst += avctx->
width * 3;
205 opcode_size = bytestream2_get_le16(&c->
gb);
216 for (i = 0; i < avctx->
height; i += 4, dst += avctx->
width * 3) {
217 for (j = 0; j < avctx->
width; j += 4, dst += 4) {
223 opcode = opcodes[x] & 15;
226 opcode = opcodes[x] >> 4;
231 offset = avctx->
width * 2;
238 color = bytestream2_get_byte(&c->
gb);
240 mask = bytestream2_get_byte(&c->
gb);
246 a = bytestream2_get_byte(&c->
gb);
247 b = bytestream2_get_byte(&c->
gb);
252 if (src + offset + avctx->
width + 4 > send)
254 mask = bytestream2_get_byte(&c->
gb);
277 code = bytestream2_get_byte(&c->
gb);
279 for (i = 0; i < 4; i++)
295 index = bytestream2_get_byte(&c->
gb);
296 count = bytestream2_get_byte(&c->
gb) + 1;
298 if (index +
count > 256)
304 for (i = 0; i <
count; i++) {
307 r = bytestream2_get_byteu(&c->
gb);
309 g = bytestream2_get_byteu(&c->
gb);
311 b = bytestream2_get_byteu(&c->
gb);
313 *out++ = 0xFF
U << 24 | r << 16 | g << 8 |
b;
318 switch (code & 0x0F) {
331 frame = bytestream2_get_byte(&c->
gb);
350 code = bytestream2_get_byteu(&c->
gb);
351 count =
FFABS(code) + 1;
353 if (dst + count > end)
356 memset(dst, bytestream2_get_byteu(&c->
gb), count);
369 for (i = 0; i < avctx->
height; i++) {
370 memcpy(dst, src, avctx->
width);
402 int16_t *output_samples;
404 int frames,
ret, i, j, k;
414 output_samples = (int16_t *)frame->
data[0];
415 for (i = 0; i < frames; i++) {
416 t = buf + 256 *
sizeof(uint16_t);
418 for (k = 0; k < 2; k++) {
419 *output_samples++ =
AV_RL16(buf + *t * 2);
This structure describes decoded (raw) audio or video data.
static int paf_aud_decode(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *pkt)
#define PAF_SOUND_FRAME_SIZE
static av_cold int paf_aud_init(AVCodecContext *avctx)
static av_cold int init(AVCodecContext *avctx)
static av_cold int paf_vid_init(AVCodecContext *avctx)
static void copy_color_mask(AVCodecContext *avctx, uint8_t mask, uint8_t *dst, uint8_t color)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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)
#define AV_CH_LAYOUT_STEREO
static av_always_inline unsigned int bytestream2_get_bufferu(GetByteContext *g, uint8_t *dst, unsigned int size)
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
enum AVSampleFormat sample_fmt
audio sample format
static int get_video_page_offset(AVCodecContext *avctx, uint8_t a, uint8_t b)
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
static const uint8_t offset[511][2]
static av_cold int end(AVCodecContext *avctx)
const char * name
Name of the codec implementation.
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by a given frame.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
static av_cold int paf_vid_close(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
static int paf_vid_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Libavcodec external API header.
uint64_t channel_layout
Audio channel layout.
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
static int64_t video_size
enum AVPictureType pict_type
Picture type of the frame.
static void copy_src_mask(AVCodecContext *avctx, uint8_t mask, uint8_t *dst, const uint8_t *src)
AVCodec ff_paf_audio_decoder
int width
picture width / height.
static void copy4h(AVCodecContext *avctx, uint8_t *dst)
static av_always_inline int bytestream2_tell(GetByteContext *g)
const AVS_VideoInfo int align
AVCodec ff_paf_video_decoder
main external API structure.
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int palette_has_changed
Tell user application that palette has changed from previous frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define PAF_SOUND_SAMPLES
static int decode_0(AVCodecContext *avctx, uint8_t code, uint8_t *pkt)
common internal api header.
#define AVERROR_INVALIDDATA
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));returnNULL;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);returnNULL;}returnac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);ff_audio_convert_init_arm(ac);ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
int channels
number of audio channels
static void copy_block4(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
int key_frame
1 -> keyframe, 0-> not
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
8 bit with PIX_FMT_RGB32 palette
static const uint8_t block_sequences[16][8]
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...