Go to the documentation of this file.
85 n = (chunk_id & 0x04) ? 4 : 6;
90 for (
i=0;
i < 256;
i++) {
91 if ((chunk_id & 0x01) && !(
mask >>= 1)) {
100 if (!(chunk_id & 0x01) || (
flag &
mask)) {
103 if ((
data + n) > eod)
106 for (k = 0; k < 4; ++k) {
108 for (kk = 0; kk < 3; ++kk)
113 u = *(int8_t *)
data++;
114 v = *(int8_t *)
data++;
118 g = *p++ - (
u/2) - v;
137 uint8_t *cb0, *cb1, *cb2, *cb3;
139 char *ip0, *ip1, *ip2, *ip3;
144 for (y=strip->
y1; y < strip->y2; y+=4) {
147 ip0 = ip1 = ip2 = ip3 =
s->frame->data[0] +
148 (
s->palette_video?strip->
x1:strip->
x1*3) + (y *
s->frame->linesize[0]);
149 if(
s->avctx->height - y > 1) {
150 ip1 = ip0 +
s->frame->linesize[0];
151 if(
s->avctx->height - y > 2) {
152 ip2 = ip1 +
s->frame->linesize[0];
153 if(
s->avctx->height - y > 3) {
154 ip3 = ip2 +
s->frame->linesize[0];
163 for (x=strip->
x1; x < strip->x2; x+=4) {
164 if ((chunk_id & 0x01) && !(
mask >>= 1)) {
165 if ((
data + 4) > eod)
173 if (!(chunk_id & 0x01) || (
flag &
mask)) {
174 if (!(chunk_id & 0x02) && !(
mask >>= 1)) {
175 if ((
data + 4) > eod)
183 if ((chunk_id & 0x02) || (~
flag &
mask)) {
189 if (
s->palette_video) {
190 ip3[0] = ip3[1] = ip2[0] = ip2[1] = p[6];
191 ip3[2] = ip3[3] = ip2[2] = ip2[3] = p[9];
192 ip1[0] = ip1[1] = ip0[0] = ip0[1] = p[0];
193 ip1[2] = ip1[3] = ip0[2] = ip0[3] = p[3];
196 memcpy(ip3 + 0, p, 3); memcpy(ip3 + 3, p, 3);
197 memcpy(ip2 + 0, p, 3); memcpy(ip2 + 3, p, 3);
199 memcpy(ip3 + 6, p, 3); memcpy(ip3 + 9, p, 3);
200 memcpy(ip2 + 6, p, 3); memcpy(ip2 + 9, p, 3);
202 memcpy(ip1 + 0, p, 3); memcpy(ip1 + 3, p, 3);
203 memcpy(ip0 + 0, p, 3); memcpy(ip0 + 3, p, 3);
205 memcpy(ip1 + 6, p, 3); memcpy(ip1 + 9, p, 3);
206 memcpy(ip0 + 6, p, 3); memcpy(ip0 + 9, p, 3);
210 if ((
data + 4) > eod)
217 if (
s->palette_video) {
240 memcpy(ip3 + 0, cb2 + 6, 6);
241 memcpy(ip3 + 6, cb3 + 6, 6);
242 memcpy(ip2 + 0, cb2 + 0, 6);
243 memcpy(ip2 + 6, cb3 + 0, 6);
244 memcpy(ip1 + 0, cb0 + 6, 6);
245 memcpy(ip1 + 6, cb1 + 6, 6);
246 memcpy(ip0 + 0, cb0 + 0, 6);
247 memcpy(ip0 + 6, cb1 + 0, 6);
253 if (
s->palette_video) {
257 ip0 += 12; ip1 += 12;
258 ip2 += 12; ip3 += 12;
270 int chunk_id, chunk_size;
273 if (strip->
x2 >
s->width ||
274 strip->
y2 >
s->height ||
275 strip->
x1 >= strip->
x2 || strip->
y1 >= strip->
y2)
278 while ((
data + 4) <= eod) {
285 chunk_size = ((
data + chunk_size) > eod) ? (eod -
data) : chunk_size;
321 int encoded_buf_size;
324 encoded_buf_size =
AV_RB24(&
s->data[1]);
326 if (
s->size < encoded_buf_size * (int64_t)(100 -
s->avctx->discard_damaged_percentage) / 100)
330 if (
s->sega_film_skip_bytes == -1) {
331 if (!encoded_buf_size) {
335 if (encoded_buf_size !=
s->size && (
s->size % encoded_buf_size) != 0) {
343 (
s->data[10] == 0xFE) &&
344 (
s->data[11] == 0x00) &&
345 (
s->data[12] == 0x00) &&
346 (
s->data[13] == 0x06) &&
347 (
s->data[14] == 0x00) &&
348 (
s->data[15] == 0x00))
349 s->sega_film_skip_bytes = 6;
351 s->sega_film_skip_bytes = 2;
353 s->sega_film_skip_bytes = 0;
356 if (
s->size < 10 +
s->sega_film_skip_bytes + num_strips * 12)
360 const uint8_t *
data =
s->data + 10 +
s->sega_film_skip_bytes;
362 if (strip_size < 12 || strip_size > encoded_buf_size)
371 const uint8_t *eod = (
s->data +
s->size);
372 int i,
result, strip_size, frame_flags, num_strips;
375 frame_flags =
s->data[0];
378 s->data += 10 +
s->sega_film_skip_bytes;
382 s->frame->key_frame = 0;
384 for (
i=0;
i < num_strips;
i++) {
385 if ((
s->data + 12) > eod)
388 s->strips[
i].id =
s->data[0];
390 if (!(
s->strips[
i].y1 =
AV_RB16 (&
s->data[4])))
391 s->strips[
i].y2 = (
s->strips[
i].y1 = y0) +
AV_RB16 (&
s->data[8]);
397 if (
s->strips[
i].id == 0x10)
398 s->frame->key_frame = 1;
400 strip_size =
AV_RB24 (&
s->data[1]) - 12;
404 strip_size = ((
s->data + strip_size) > eod) ? (eod -
s->data) : strip_size;
406 if ((
i > 0) && !(frame_flags & 0x01)) {
407 memcpy (
s->strips[
i].v4_codebook,
s->strips[
i-1].v4_codebook,
408 sizeof(
s->strips[
i].v4_codebook));
409 memcpy (
s->strips[
i].v1_codebook,
s->strips[
i-1].v1_codebook,
410 sizeof(
s->strips[
i].v1_codebook));
418 s->data += strip_size;
419 y0 =
s->strips[
i].y2;
429 s->width = (avctx->
width + 3) & ~3;
430 s->height = (avctx->
height + 3) & ~3;
432 s->sega_film_skip_bytes = -1;
436 s->palette_video = 0;
439 s->palette_video = 1;
451 void *
data,
int *got_frame,
455 int ret = 0, buf_size = avpkt->
size;
479 if (
s->palette_video) {
483 s->frame->palette_has_changed = 1;
494 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...
static av_cold int init(AVCodecContext *avctx)
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
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, buffer_size_t *size)
AVCodec ff_cinepak_decoder
#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.
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).
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.
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