FFmpeg: libavformat/cinedec.c Source File
Go to the documentation of this file. 1 /*
2 * Phantom Cine demuxer
3 * Copyright (c) 2010-2011 Peter Ross <pross@xvid.org>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * Phantom Cine demuxer
25 * @author Peter Ross <pross@xvid.org>
26 */
27
35
40
41 /** Compression */
42 enum {
45 CC_UNINT = 2
/**< Uninterpolated color image (CFA field indicates color ordering) */
46 };
47
48 /** Color Filter Array */
49 enum {
57 };
58
59 #define CFA_TLGRAY 0x80000000U
60 #define CFA_TRGRAY 0x40000000U
61 #define CFA_BLGRAY 0x20000000U
62 #define CFA_BRGRAY 0x10000000U
63
65 {
66 int HeaderSize;
67 if (
p->buf[0] ==
'C' &&
p->buf[1] ==
'I' &&
// Type
68 (HeaderSize =
AV_RL16(
p->buf + 2)) >= 0x2C &&
// HeaderSize
70 AV_RL16(
p->buf + 6) <= 1 &&
// Version
71 AV_RL32(
p->buf + 20) &&
// ImageCount
72 AV_RL32(
p->buf + 24) >= HeaderSize &&
// OffImageHeader
73 AV_RL32(
p->buf + 28) >= HeaderSize &&
// OffSetup
74 AV_RL32(
p->buf + 32) >= HeaderSize)
// OffImageOffsets
76 return 0;
77 }
78
80 {
81 if (
value || allow_zero) {
83 }
84 return 0;
85 }
86
88 {
89 if (
value != 0 || allow_zero) {
93 }
94 return 0;
95 }
96
98 {
101 unsigned int version, compression, offImageHeader, offSetup, offImageOffsets, biBitCount, length, CFA;
102 int vflip;
105
107 if (!st)
112
113 /* CINEFILEHEADER structure */
115
121 }
122
123 avio_skip(pb, 12);
// FirstMovieImage, TotalImageCount, FirstImageNumber
124
129
131
132 /* BITMAPINFOHEADER structure */
137
140
142 if (biBitCount != 8 && biBitCount != 16 && biBitCount != 24 && biBitCount != 48) {
145 }
146
149 vflip = 0;
150 break;
151 case 0x100: /* BI_PACKED */
153 vflip = 1;
154 break;
155 default:
158 }
159
161
162 /* parse SETUP structure */
164 avio_skip(pb, 140);
// FrameRatae16 .. descriptionOld
168 if (length < 0x163C) {
171 }
172
179 }
181 }
182
184
186
187 avio_skip(pb, 20);
// Shutter .. bEnableColor
188
193
195
199
200 avio_skip(pb, 12 + 16);
// Reserved1 .. AutoExpRect
204
206
207 if (compression ==
CC_RGB) {
208 if (biBitCount == 8) {
210 } else if (biBitCount == 16) {
212 } else if (biBitCount == 24) {
214 } else if (biBitCount == 48) {
216 } else {
219 }
220 }
else if (compression ==
CC_UNINT) {
221 switch (CFA & 0xFFFFFF) {
223 if (biBitCount == 8) {
225 } else if (biBitCount == 16) {
227 } else {
230 }
231 break;
233 if (biBitCount == 8) {
235 } else if (biBitCount == 16) {
237 } else {
240 }
241 break;
243 if (biBitCount == 8) {
245 } else if (biBitCount == 16) {
247 } else {
250 }
251 break;
253 if (biBitCount == 8) {
255 } else if (biBitCount == 16) {
257 } else {
260 }
261 break;
262 default:
265 }
266 } else { //CC_LEAD
269 }
270
271 avio_skip(pb, 668);
// Conv8Min ... Sensor
272
274
275 avio_skip(pb, 24);
// EDRShutterNs ... ImHeightAcq
276
277 #define DESCRIPTION_SIZE 4096
286 else
288
289 avio_skip(pb, 1176);
// RisingEdge ... cmUser
290
296
297 /* parse image offsets */
298 avio_seek(pb, offImageOffsets, SEEK_SET);
303
305 }
306
307 return 0;
308 }
309
311 {
318
321
323 if (ret64 < 0)
324 return ret64;
326 if (n < 8)
332
335
339
342
346 return 0;
347 }
348
350 {
352
355
358
359 cine->
pts = timestamp;
360 return 0;
361 }
362
371 };
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
@ AV_PIX_FMT_BAYER_GBRG16LE
bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, little-endian
@ AV_PIX_FMT_BGR48LE
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
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
enum AVMediaType codec_type
General type of the encoded data.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
const FFInputFormat ff_cine_demuxer
AVStream ** streams
A list of all streams in the file.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int cine_read_header(AVFormatContext *avctx)
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
int64_t duration
Decoding: duration of the stream, in stream time base.
unsigned int avio_rl16(AVIOContext *s)
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static int set_metadata_float(AVDictionary **dict, const char *key, float value, int allow_zero)
@ AV_PIX_FMT_BAYER_RGGB16LE
bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, little-endian
@ AV_PIX_FMT_BAYER_BGGR8
bayer, BGBG..(odd line), GRGR..(even line), 8-bit samples
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
static int cine_read_packet(AVFormatContext *avctx, AVPacket *pkt)
@ AV_PIX_FMT_BAYER_RGGB8
bayer, RGRG..(odd line), GBGB..(even line), 8-bit samples
@ AV_PIX_FMT_BAYER_GRBG16LE
bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVIOContext * pb
I/O context.
This structure contains the data a format has to probe a file.
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
static int cine_read_probe(const AVProbeData *p)
int extradata_size
Size of the extradata content in bytes.
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
@ AV_PIX_FMT_BAYER_BGGR16LE
bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, little-endian
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
int flags
A combination of AV_PKT_FLAG values.
static int read_header(FFV1Context *f, RangeCoder *c)
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
@ AV_PIX_FMT_BAYER_GBRG8
bayer, GBGB..(odd line), RGRG..(even line), 8-bit samples
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set() that converts the value to a string and stores it.
char * av_strdup(const char *s)
Duplicate a string.
static int read_probe(const AVProbeData *p)
@ AV_PIX_FMT_GRAY16LE
Y , 16bpp, little-endian.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
#define avpriv_request_sample(...)
static int set_metadata_int(AVDictionary **dict, const char *key, int value, int allow_zero)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
uint64_t avio_rl64(AVIOContext *s)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
@ CC_UNINT
Uninterpolated color image (CFA field indicates color ordering)
void * priv_data
Format private data.
@ AV_PIX_FMT_BAYER_GRBG8
bayer, GRGR..(odd line), BGBG..(even line), 8-bit samples
static int cine_read_seek(AVFormatContext *avctx, int stream_index, int64_t timestamp, int flags)
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Generated on Tue Nov 18 2025 19:23:24 for FFmpeg by
doxygen
1.8.17