Go to the documentation of this file.
78 int chunk_id,
int size,
const uint8_t *
data)
86 n = (chunk_id & 0x04) ? 4 : 6;
91 for (
i=0;
i < 256;
i++) {
92 if ((chunk_id & 0x01) && !(
mask >>= 1)) {
101 if (!(chunk_id & 0x01) || (
flag &
mask)) {
104 if ((
data + n) > eod)
107 for (k = 0; k < 4; ++k) {
109 for (kk = 0; kk < 3; ++kk)
114 u = *(int8_t *)
data++;
115 v = *(int8_t *)
data++;
119 g = *p++ - (
u/2) - v;
134 int chunk_id,
int size,
const uint8_t *
data)
138 uint8_t *cb0, *cb1, *cb2, *cb3;
140 char *ip0, *ip1, *ip2, *ip3;
145 for (y=strip->
y1; y < strip->y2; y+=4) {
148 ip0 = ip1 = ip2 = ip3 =
s->frame->data[0] +
149 (
s->palette_video?strip->
x1:strip->
x1*3) + (y *
s->frame->linesize[0]);
150 if(
s->avctx->height - y > 1) {
151 ip1 = ip0 +
s->frame->linesize[0];
152 if(
s->avctx->height - y > 2) {
153 ip2 = ip1 +
s->frame->linesize[0];
154 if(
s->avctx->height - y > 3) {
155 ip3 = ip2 +
s->frame->linesize[0];
164 for (x=strip->
x1; x < strip->x2; x+=4) {
165 if ((chunk_id & 0x01) && !(
mask >>= 1)) {
166 if ((
data + 4) > eod)
174 if (!(chunk_id & 0x01) || (
flag &
mask)) {
175 if (!(chunk_id & 0x02) && !(
mask >>= 1)) {
176 if ((
data + 4) > eod)
184 if ((chunk_id & 0x02) || (~
flag &
mask)) {
190 if (
s->palette_video) {
191 ip3[0] = ip3[1] = ip2[0] = ip2[1] = p[6];
192 ip3[2] = ip3[3] = ip2[2] = ip2[3] = p[9];
193 ip1[0] = ip1[1] = ip0[0] = ip0[1] = p[0];
194 ip1[2] = ip1[3] = ip0[2] = ip0[3] = p[3];
197 memcpy(ip3 + 0, p, 3); memcpy(ip3 + 3, p, 3);
198 memcpy(ip2 + 0, p, 3); memcpy(ip2 + 3, p, 3);
200 memcpy(ip3 + 6, p, 3); memcpy(ip3 + 9, p, 3);
201 memcpy(ip2 + 6, p, 3); memcpy(ip2 + 9, p, 3);
203 memcpy(ip1 + 0, p, 3); memcpy(ip1 + 3, p, 3);
204 memcpy(ip0 + 0, p, 3); memcpy(ip0 + 3, p, 3);
206 memcpy(ip1 + 6, p, 3); memcpy(ip1 + 9, p, 3);
207 memcpy(ip0 + 6, p, 3); memcpy(ip0 + 9, p, 3);
211 if ((
data + 4) > eod)
218 if (
s->palette_video) {
241 memcpy(ip3 + 0, cb2 + 6, 6);
242 memcpy(ip3 + 6, cb3 + 6, 6);
243 memcpy(ip2 + 0, cb2 + 0, 6);
244 memcpy(ip2 + 6, cb3 + 0, 6);
245 memcpy(ip1 + 0, cb0 + 6, 6);
246 memcpy(ip1 + 6, cb1 + 6, 6);
247 memcpy(ip0 + 0, cb0 + 0, 6);
248 memcpy(ip0 + 6, cb1 + 0, 6);
254 if (
s->palette_video) {
258 ip0 += 12; ip1 += 12;
259 ip2 += 12; ip3 += 12;
271 int chunk_id, chunk_size;
274 if (strip->
x2 >
s->width ||
275 strip->
y2 >
s->height ||
276 strip->
x1 >= strip->
x2 || strip->
y1 >= strip->
y2)
279 while ((
data + 4) <= eod) {
286 chunk_size = ((
data + chunk_size) > eod) ? (eod -
data) : chunk_size;
322 int encoded_buf_size;
325 encoded_buf_size =
AV_RB24(&
s->data[1]);
327 if (
s->size < encoded_buf_size * (int64_t)(100 -
s->avctx->discard_damaged_percentage) / 100)
331 if (
s->sega_film_skip_bytes == -1) {
332 if (!encoded_buf_size) {
336 if (encoded_buf_size !=
s->size && (
s->size % encoded_buf_size) != 0) {
344 (
s->data[10] == 0xFE) &&
345 (
s->data[11] == 0x00) &&
346 (
s->data[12] == 0x00) &&
347 (
s->data[13] == 0x06) &&
348 (
s->data[14] == 0x00) &&
349 (
s->data[15] == 0x00))
350 s->sega_film_skip_bytes = 6;
352 s->sega_film_skip_bytes = 2;
354 s->sega_film_skip_bytes = 0;
357 if (
s->size < 10 +
s->sega_film_skip_bytes + num_strips * 12)
361 const uint8_t *
data =
s->data + 10 +
s->sega_film_skip_bytes;
363 if (strip_size < 12 || strip_size > encoded_buf_size)
372 const uint8_t *eod = (
s->data +
s->size);
373 int i,
result, strip_size, frame_flags, num_strips;
376 frame_flags =
s->data[0];
379 s->data += 10 +
s->sega_film_skip_bytes;
383 s->frame->key_frame = 0;
385 for (
i=0;
i < num_strips;
i++) {
386 if ((
s->data + 12) > eod)
389 s->strips[
i].id =
s->data[0];
391 if (!(
s->strips[
i].y1 =
AV_RB16 (&
s->data[4])))
392 s->strips[
i].y2 = (
s->strips[
i].y1 = y0) +
AV_RB16 (&
s->data[8]);
398 if (
s->strips[
i].id == 0x10)
399 s->frame->key_frame = 1;
401 strip_size =
AV_RB24 (&
s->data[1]) - 12;
405 strip_size = ((
s->data + strip_size) > eod) ? (eod -
s->data) : strip_size;
407 if ((
i > 0) && !(frame_flags & 0x01)) {
408 memcpy (
s->strips[
i].v4_codebook,
s->strips[
i-1].v4_codebook,
409 sizeof(
s->strips[
i].v4_codebook));
410 memcpy (
s->strips[
i].v1_codebook,
s->strips[
i-1].v1_codebook,
411 sizeof(
s->strips[
i].v1_codebook));
419 s->data += strip_size;
420 y0 =
s->strips[
i].y2;
430 s->width = (avctx->
width + 3) & ~3;
431 s->height = (avctx->
height + 3) & ~3;
433 s->sega_film_skip_bytes = -1;
437 s->palette_video = 0;
440 s->palette_video = 1;
452 void *
data,
int *got_frame,
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)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
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.
const AVCodec ff_cinepak_decoder
uint8_t cvid_codebook[12]
static int cinepak_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
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]
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
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 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
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.
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