Go to the documentation of this file.
79 int chunk_id,
int size,
const uint8_t *
data)
87 n = (chunk_id & 0x04) ? 4 : 6;
92 for (
i=0;
i < 256;
i++) {
93 if ((chunk_id & 0x01) && !(
mask >>= 1)) {
102 if (!(chunk_id & 0x01) || (
flag &
mask)) {
105 if ((
data + n) > eod)
108 for (k = 0; k < 4; ++k) {
110 for (kk = 0; kk < 3; ++kk)
115 u = *(int8_t *)
data++;
116 v = *(int8_t *)
data++;
120 g = *p++ - (
u/2) - v;
135 int chunk_id,
int size,
const uint8_t *
data)
139 uint8_t *cb0, *cb1, *cb2, *cb3;
141 char *ip0, *ip1, *ip2, *ip3;
146 for (y=strip->
y1; y < strip->y2; y+=4) {
149 ip0 = ip1 = ip2 = ip3 =
s->frame->data[0] +
150 (
s->palette_video?strip->
x1:strip->
x1*3) + (y *
s->frame->linesize[0]);
151 if(
s->avctx->height - y > 1) {
152 ip1 = ip0 +
s->frame->linesize[0];
153 if(
s->avctx->height - y > 2) {
154 ip2 = ip1 +
s->frame->linesize[0];
155 if(
s->avctx->height - y > 3) {
156 ip3 = ip2 +
s->frame->linesize[0];
165 for (x=strip->
x1; x < strip->x2; x+=4) {
166 if ((chunk_id & 0x01) && !(
mask >>= 1)) {
167 if ((
data + 4) > eod)
175 if (!(chunk_id & 0x01) || (
flag &
mask)) {
176 if (!(chunk_id & 0x02) && !(
mask >>= 1)) {
177 if ((
data + 4) > eod)
185 if ((chunk_id & 0x02) || (~
flag &
mask)) {
191 if (
s->palette_video) {
192 ip3[0] = ip3[1] = ip2[0] = ip2[1] = p[6];
193 ip3[2] = ip3[3] = ip2[2] = ip2[3] = p[9];
194 ip1[0] = ip1[1] = ip0[0] = ip0[1] = p[0];
195 ip1[2] = ip1[3] = ip0[2] = ip0[3] = p[3];
198 memcpy(ip3 + 0, p, 3); memcpy(ip3 + 3, p, 3);
199 memcpy(ip2 + 0, p, 3); memcpy(ip2 + 3, p, 3);
201 memcpy(ip3 + 6, p, 3); memcpy(ip3 + 9, p, 3);
202 memcpy(ip2 + 6, p, 3); memcpy(ip2 + 9, p, 3);
204 memcpy(ip1 + 0, p, 3); memcpy(ip1 + 3, p, 3);
205 memcpy(ip0 + 0, p, 3); memcpy(ip0 + 3, p, 3);
207 memcpy(ip1 + 6, p, 3); memcpy(ip1 + 9, p, 3);
208 memcpy(ip0 + 6, p, 3); memcpy(ip0 + 9, p, 3);
212 if ((
data + 4) > eod)
219 if (
s->palette_video) {
242 memcpy(ip3 + 0, cb2 + 6, 6);
243 memcpy(ip3 + 6, cb3 + 6, 6);
244 memcpy(ip2 + 0, cb2 + 0, 6);
245 memcpy(ip2 + 6, cb3 + 0, 6);
246 memcpy(ip1 + 0, cb0 + 6, 6);
247 memcpy(ip1 + 6, cb1 + 6, 6);
248 memcpy(ip0 + 0, cb0 + 0, 6);
249 memcpy(ip0 + 6, cb1 + 0, 6);
255 if (
s->palette_video) {
259 ip0 += 12; ip1 += 12;
260 ip2 += 12; ip3 += 12;
272 int chunk_id, chunk_size;
275 if (strip->
x2 >
s->width ||
276 strip->
y2 >
s->height ||
277 strip->
x1 >= strip->
x2 || strip->
y1 >= strip->
y2)
280 while ((
data + 4) <= eod) {
287 chunk_size = ((
data + chunk_size) > eod) ? (eod -
data) : chunk_size;
323 int encoded_buf_size;
326 encoded_buf_size =
AV_RB24(&
s->data[1]);
328 if (
s->size < encoded_buf_size * (int64_t)(100 -
s->avctx->discard_damaged_percentage) / 100)
332 if (
s->sega_film_skip_bytes == -1) {
333 if (!encoded_buf_size) {
337 if (encoded_buf_size !=
s->size && (
s->size % encoded_buf_size) != 0) {
345 (
s->data[10] == 0xFE) &&
346 (
s->data[11] == 0x00) &&
347 (
s->data[12] == 0x00) &&
348 (
s->data[13] == 0x06) &&
349 (
s->data[14] == 0x00) &&
350 (
s->data[15] == 0x00))
351 s->sega_film_skip_bytes = 6;
353 s->sega_film_skip_bytes = 2;
355 s->sega_film_skip_bytes = 0;
358 if (
s->size < 10 +
s->sega_film_skip_bytes + num_strips * 12)
362 const uint8_t *
data =
s->data + 10 +
s->sega_film_skip_bytes;
364 if (strip_size < 12 || strip_size > encoded_buf_size)
373 const uint8_t *eod = (
s->data +
s->size);
374 int i,
result, strip_size, frame_flags, num_strips;
377 frame_flags =
s->data[0];
380 s->data += 10 +
s->sega_film_skip_bytes;
384 s->frame->key_frame = 0;
386 for (
i=0;
i < num_strips;
i++) {
387 if ((
s->data + 12) > eod)
390 s->strips[
i].id =
s->data[0];
392 if (!(
s->strips[
i].y1 =
AV_RB16 (&
s->data[4])))
393 s->strips[
i].y2 = (
s->strips[
i].y1 = y0) +
AV_RB16 (&
s->data[8]);
399 if (
s->strips[
i].id == 0x10)
400 s->frame->key_frame = 1;
402 strip_size =
AV_RB24 (&
s->data[1]) - 12;
406 strip_size = ((
s->data + strip_size) > eod) ? (eod -
s->data) : strip_size;
408 if ((
i > 0) && !(frame_flags & 0x01)) {
409 memcpy (
s->strips[
i].v4_codebook,
s->strips[
i-1].v4_codebook,
410 sizeof(
s->strips[
i].v4_codebook));
411 memcpy (
s->strips[
i].v1_codebook,
s->strips[
i-1].v1_codebook,
412 sizeof(
s->strips[
i].v1_codebook));
420 s->data += strip_size;
421 y0 =
s->strips[
i].y2;
431 s->width = (avctx->
width + 3) & ~3;
432 s->height = (avctx->
height + 3) & ~3;
434 s->sega_film_skip_bytes = -1;
438 s->palette_video = 0;
441 s->palette_video = 1;
455 const uint8_t *buf = avpkt->
data;
456 int ret = 0, buf_size = avpkt->
size;
480 if (
s->palette_video) {
488 if (
s->palette_video)
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
#define u(width, name, range_min, range_max)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
AVCodec p
The public AVCodec.
uint8_t cvid_codebook[12]
static int cinepak_predecode_check(CinepakContext *s)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
#define FF_CODEC_DECODE_CB(func)
static int cinepak_decode_strip(CinepakContext *s, cvid_strip *strip, const uint8_t *data, int size)
cvid_codebook v1_codebook[256]
and forward the result(frame or status change) to the corresponding input. If nothing is possible
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
cvid_codebook v4_codebook[256]
static int cinepak_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static void cinepak_decode_codebook(cvid_codebook *codebook, int chunk_id, int size, const uint8_t *data)
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
const FFCodec ff_cinepak_decoder
static av_cold int cinepak_decode_init(AVCodecContext *avctx)
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define i(width, name, range_min, range_max)
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
static int cinepak_decode_vectors(CinepakContext *s, cvid_strip *strip, int chunk_id, int size, const uint8_t *data)
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.
main external API structure.
static av_cold int cinepak_decode_end(AVCodecContext *avctx)
#define avpriv_request_sample(...)
This structure stores compressed data.
cvid_strip strips[MAX_STRIPS]
int width
picture width / height.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ff_copy_palette(void *dst, const AVPacket *src, void *logctx)
Check whether the side-data of src contains a palette of size AVPALETTE_SIZE; if so,...
static int cinepak_decode(CinepakContext *s)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
const unsigned char * data
static const unsigned codebook[256][2]
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16