FFmpeg
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
Go to the source code of this file.
Data Structures | |
struct | VqaContext |
Macros | |
#define | PALETTE_COUNT 256 |
#define | VQA_HEADER_SIZE 0x2A |
#define | MAX_CODEBOOK_VECTORS 0xFF00 |
#define | SOLID_PIXEL_VECTORS 0x100 |
#define | MAX_VECTORS (MAX_CODEBOOK_VECTORS + SOLID_PIXEL_VECTORS) |
#define | MAX_CODEBOOK_SIZE (MAX_VECTORS * 4 * 4) |
#define | CBF0_TAG MKBETAG('C', 'B', 'F', '0') |
#define | CBFZ_TAG MKBETAG('C', 'B', 'F', 'Z') |
#define | CBP0_TAG MKBETAG('C', 'B', 'P', '0') |
#define | CBPZ_TAG MKBETAG('C', 'B', 'P', 'Z') |
#define | CPL0_TAG MKBETAG('C', 'P', 'L', '0') |
#define | CPLZ_TAG MKBETAG('C', 'P', 'L', 'Z') |
#define | VPTZ_TAG MKBETAG('V', 'P', 'T', 'Z') |
#define | CHECK_COUNT() |
#define | CHECK_COPY(idx) |
Functions | |
static av_cold int | vqa_decode_init (AVCodecContext *avctx) |
static int | decode_format80 (VqaContext *s, int src_size, unsigned char *dest, int dest_size, int check_size) |
static int | vqa_decode_chunk (VqaContext *s, AVFrame *frame) |
static int | vqa_decode_frame (AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) |
static av_cold int | vqa_decode_end (AVCodecContext *avctx) |
Variables | |
AVCodec | ff_vqa_decoder |
VQA Video Decoder.
The VQA video decoder outputs PAL8 or RGB555 colorspace data, depending on the type of data in the file.
This decoder needs the 42-byte VQHD header from the beginning of the VQA file passed through the extradata field. The VQHD header is laid out as:
bytes 0-3 chunk fourcc: 'VQHD' bytes 4-7 chunk size in big-endian format, should be 0x0000002A bytes 8-49 VQHD chunk data
Bytes 8-49 are what this decoder expects to see.
Briefly, VQA is a vector quantized animation format that operates in a VGA palettized colorspace. It operates on pixel vectors (blocks) of either 4x2 or 4x4 in size. Compressed VQA chunks can contain vector codebooks, palette information, and code maps for rendering vectors onto frames. Any of these components can also be compressed with a run-length encoding (RLE) algorithm commonly referred to as "format80".
VQA takes a novel approach to rate control. Each group of n frames (usually, n = 8) relies on a different vector codebook. Rather than transporting an entire codebook every 8th frame, the new codebook is broken up into 8 pieces and sent along with the compressed video chunks for each of the 8 frames preceding the 8 frames which require the codebook. A full codebook is also sent on the very first frame of a file. This is an interesting technique, although it makes random file seeking difficult despite the fact that the frames are all intracoded.
V1,2 VQA uses 12-bit codebook indexes. If the 12-bit indexes were packed into bytes and then RLE compressed, bytewise, the results would be poor. That is why the coding method divides each index into 2 parts, the top 4 bits and the bottom 8 bits, then RL encodes the 4-bit pieces together and the 8-bit pieces together. If most of the vectors are clustered into one group of 256 vectors, most of the 4-bit index pieces should be the same.
Definition in file vqavideo.c.
#define PALETTE_COUNT 256 |
Definition at line 76 of file vqavideo.c.
Referenced by vqa_decode_frame().
#define VQA_HEADER_SIZE 0x2A |
Definition at line 77 of file vqavideo.c.
Referenced by vqa_decode_init().
#define MAX_CODEBOOK_VECTORS 0xFF00 |
Definition at line 81 of file vqavideo.c.
#define SOLID_PIXEL_VECTORS 0x100 |
Definition at line 82 of file vqavideo.c.
#define MAX_VECTORS (MAX_CODEBOOK_VECTORS + SOLID_PIXEL_VECTORS) |
Definition at line 83 of file vqavideo.c.
#define MAX_CODEBOOK_SIZE (MAX_VECTORS * 4 * 4) |
Definition at line 84 of file vqavideo.c.
Referenced by vqa_decode_chunk(), and vqa_decode_init().
Definition at line 86 of file vqavideo.c.
Referenced by vqa_decode_chunk().
Definition at line 87 of file vqavideo.c.
Referenced by vqa_decode_chunk().
Definition at line 88 of file vqavideo.c.
Referenced by vqa_decode_chunk().
Definition at line 89 of file vqavideo.c.
Referenced by vqa_decode_chunk().
Definition at line 90 of file vqavideo.c.
Referenced by vqa_decode_chunk().
Definition at line 91 of file vqavideo.c.
Referenced by vqa_decode_chunk().
Definition at line 92 of file vqavideo.c.
Referenced by vqa_decode_chunk().
#define CHECK_COUNT | ( | ) |
Definition at line 208 of file vqavideo.c.
Referenced by decode_format80(), and mpegts_probe().
#define CHECK_COPY | ( | idx | ) |
Definition at line 216 of file vqavideo.c.
Referenced by decode_format80().
|
static |
Definition at line 121 of file vqavideo.c.
|
static |
Definition at line 225 of file vqavideo.c.
Referenced by vqa_decode_chunk().
|
static |
Definition at line 315 of file vqavideo.c.
Referenced by vqa_decode_frame().
|
static |
Definition at line 602 of file vqavideo.c.
|
static |
Definition at line 627 of file vqavideo.c.
AVCodec ff_vqa_decoder |
Definition at line 638 of file vqavideo.c.