quicktime.h
Go to the documentation of this file.
/*******************************************************************************
quicktime.h
libquicktime - A library for reading and writing quicktime/avi/mp4 files.
http://libquicktime.sourceforge.net
Copyright (C) 2002 Heroine Virtual Ltd.
Copyright (C) 2002-2011 Members of the libquicktime project.
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along
with this library; if not, write to the Free Software Foundation, Inc., 51
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*******************************************************************************/
#ifndef QUICKTIME_H
#define QUICKTIME_H
#ifdef __cplusplus
extern "C" {
#endif
#include <inttypes.h>
#include <stddef.h>
#pragma GCC visibility push(default)
/* Some public enums needed by most subsequent headers */
typedef struct lqt_codec_info_s lqt_codec_info_t;
typedef enum
{
LQT_LOG_ERROR = (1<<0),
LQT_LOG_WARNING = (1<<1),
LQT_LOG_INFO = (1<<2),
LQT_LOG_DEBUG = (1<<3),
} lqt_log_level_t;
typedef void (*lqt_log_callback_t)(lqt_log_level_t level,
const char * domain,
const char * message,
void * data);
typedef enum
{
LQT_FILE_NONE = 0,
LQT_FILE_QT_OLD = (1<<0),
LQT_FILE_QT = (1<<1),
LQT_FILE_AVI = (1<<2),
LQT_FILE_AVI_ODML = (1<<3),
LQT_FILE_MP4 = (1<<4),
LQT_FILE_M4A = (1<<5),
LQT_FILE_3GP = (1<<6),
} lqt_file_type_t;
typedef enum
{
LQT_CHANNEL_UNKNOWN,
LQT_CHANNEL_FRONT_LEFT,
LQT_CHANNEL_FRONT_RIGHT,
LQT_CHANNEL_FRONT_CENTER,
LQT_CHANNEL_FRONT_CENTER_LEFT,
LQT_CHANNEL_FRONT_CENTER_RIGHT,
LQT_CHANNEL_BACK_CENTER,
LQT_CHANNEL_BACK_LEFT,
LQT_CHANNEL_BACK_RIGHT,
LQT_CHANNEL_SIDE_LEFT,
LQT_CHANNEL_SIDE_RIGHT,
LQT_CHANNEL_LFE,
} lqt_channel_t;
typedef enum
{
LQT_INTERLACE_NONE = 0,
LQT_INTERLACE_TOP_FIRST,
LQT_INTERLACE_BOTTOM_FIRST
} lqt_interlace_mode_t;
typedef enum
{
LQT_CHROMA_PLACEMENT_DEFAULT = 0,
LQT_CHROMA_PLACEMENT_MPEG2,
LQT_CHROMA_PLACEMENT_DVPAL,
} lqt_chroma_placement_t;
typedef enum
{
LQT_SAMPLE_UNDEFINED = 0,
LQT_SAMPLE_INT8,
LQT_SAMPLE_UINT8,
LQT_SAMPLE_INT16,
LQT_SAMPLE_INT32,
LQT_SAMPLE_FLOAT,
LQT_SAMPLE_DOUBLE
} lqt_sample_format_t;
typedef struct quicktime_s quicktime_t;
/* This is the reference for all your library entry points. */
/* ===== compression formats for which codecs exist ====== */
#define QUICKTIME_DIVX "DIVX"
#define QUICKTIME_DIV3 "DIV3"
#define QUICKTIME_DV "dvc "
/* AVID DV codec can be processed with libdv as well */
#define QUICKTIME_DV_AVID "AVdv"
#define QUICKTIME_DV_AVID_A "dvcp"
/* RGB uncompressed. Allows alpha */
#define QUICKTIME_RAW "raw "
/* Jpeg Photo */
#define QUICKTIME_JPEG "jpeg"
/* Concatenated png images. Allows alpha */
#define QUICKTIME_PNG "png "
#define QUICKTIME_MJPA "mjpa"
#define QUICKTIME_YUV2 "yuv2"
#define QUICKTIME_YUV4 "yuv4"
#define QUICKTIME_YUV420 "yv12"
#define QUICKTIME_2VUY "2vuy"
#define QUICKTIME_YUVS "yuvs"
#define QUICKTIME_V308 "v308"
#define QUICKTIME_V408 "v408"
#define QUICKTIME_V210 "v210"
#define QUICKTIME_V410 "v410"
/* =================== Audio formats ======================= */
#define QUICKTIME_RAWAUDIO "raw "
#define QUICKTIME_IMA4 "ima4"
#define QUICKTIME_TWOS "twos"
#define QUICKTIME_ULAW "ulaw"
#define QUICKTIME_VORBIS "OggS"
#define QUICKTIME_MP3 ".mp3"
/* =========================== public interface ========================= // */
/* Get version information */
int quicktime_major();
int quicktime_minor();
int quicktime_release();
int quicktime_check_sig(char *path);
quicktime_t* quicktime_open(const char *filename, int rd, int wr);
int quicktime_make_streamable(char *in_path, char *out_path);
void quicktime_set_copyright(quicktime_t *file, char *string);
void quicktime_set_name(quicktime_t *file, char *string);
void quicktime_set_info(quicktime_t *file, char *string);
char* quicktime_get_copyright(quicktime_t *file);
char* quicktime_get_name(quicktime_t *file);
char* quicktime_get_info(quicktime_t *file);
int quicktime_set_audio(quicktime_t *file,
int channels,
long sample_rate,
int bits,
char *compressor);
void quicktime_set_framerate(quicktime_t *file, double framerate);
int quicktime_set_video(quicktime_t *file,
int tracks,
int frame_w,
int frame_h,
double frame_rate,
char *compressor);
void quicktime_set_jpeg(quicktime_t *file, int quality, int use_float);
void quicktime_set_parameter(quicktime_t *file, char *key, void *value);
void quicktime_set_depth(quicktime_t *file,
int depth,
int track);
void quicktime_set_cmodel(quicktime_t *file, int colormodel);
void quicktime_set_row_span(quicktime_t *file, int row_span);
int quicktime_close(quicktime_t *file);
/* get length information */
/* channel numbers start on 1 for audio and video */
long quicktime_audio_length(quicktime_t *file, int track);
long quicktime_video_length(quicktime_t *file, int track);
/* get position information */
long quicktime_audio_position(quicktime_t *file, int track);
long quicktime_video_position(quicktime_t *file, int track);
/* get file information */
int quicktime_video_tracks(quicktime_t *file);
int quicktime_audio_tracks(quicktime_t *file);
int quicktime_has_audio(quicktime_t *file);
long quicktime_sample_rate(quicktime_t *file, int track);
int quicktime_audio_bits(quicktime_t *file, int track);
int quicktime_track_channels(quicktime_t *file, int track);
char* quicktime_audio_compressor(quicktime_t *file, int track);
int quicktime_has_video(quicktime_t *file);
int quicktime_video_width(quicktime_t *file, int track);
int quicktime_video_height(quicktime_t *file, int track);
int quicktime_video_depth(quicktime_t *file, int track);
double quicktime_frame_rate(quicktime_t *file, int track);
char* quicktime_video_compressor(quicktime_t *file, int track);
/* number of bytes of raw data in this frame */
long quicktime_frame_size(quicktime_t *file, long frame, int track);
int quicktime_channel_location(quicktime_t *file, int *quicktime_track, int *quicktime_channel, int channel);
/* file positioning */
/* Remove these and see what happens :) */
// int quicktime_seek_end(quicktime_t *file);
int quicktime_seek_start(quicktime_t *file);
/* set position of file descriptor relative to a track */
int quicktime_set_audio_position(quicktime_t *file, int64_t sample, int track);
int quicktime_set_video_position(quicktime_t *file, int64_t frame, int track);
/* ========================== Access to raw data follows. */
/* write data for one quicktime track */
/* the user must handle conversion to the channels in this track */
int quicktime_write_audio(quicktime_t *file, uint8_t *audio_buffer, long samples, int track);
int quicktime_write_frame(quicktime_t *file, uint8_t *video_buffer, int64_t bytes, int track);
long quicktime_read_frame(quicktime_t *file, unsigned char *video_buffer, int track);
/* for reading frame using a library that needs a file descriptor */
/* Frame caching doesn't work here. */
int quicktime_read_frame_init(quicktime_t *file, int track);
int quicktime_read_frame_end(quicktime_t *file, int track);
/* One keyframe table for each track */
long quicktime_get_keyframe_before(quicktime_t *file, long frame, int track);
void quicktime_insert_keyframe(quicktime_t *file, long frame, int track);
/* Track has keyframes */
int quicktime_has_keyframes(quicktime_t *file, int track);
/* ===================== Access to built in codecs follows. */
/* If the codec for this track is supported in the library return 1. */
int quicktime_supported_video(quicktime_t *file, int track);
int quicktime_supported_audio(quicktime_t *file, int track);
int quicktime_reads_cmodel(quicktime_t *file,
int colormodel,
int track);
int quicktime_writes_cmodel(quicktime_t *file,
int colormodel,
int track);
/* Hacks for temporal codec */
int quicktime_divx_is_key(unsigned char *data, long size);
int quicktime_divx_write_vol(unsigned char *data_start,
int vol_width,
int vol_height,
int time_increment_resolution,
double frame_rate);
int quicktime_divx_has_vol(unsigned char *data);
int quicktime_div3_is_key(unsigned char *data, long size);
int quicktime_encode_video(quicktime_t *file,
unsigned char **row_pointers,
int track);
int quicktime_decode_video(quicktime_t *file,
unsigned char **row_pointers,
int track);
long quicktime_decode_scaled(quicktime_t *file,
int in_x, /* Location of input frame to take picture */
int in_y,
int in_w,
int in_h,
int out_w, /* Dimensions of output frame */
int out_h,
int color_model, /* One of the color models defined above */
unsigned char **row_pointers,
int track);
/* Decode or encode audio for a single channel into the buffer. */
/* Pass a buffer for the _i or the _f argument if you want int16 or float data. */
/* Notice that encoding requires an array of pointers to each channel. */
int quicktime_decode_audio(quicktime_t *file, int16_t *output_i, float *output_f, long samples, int channel);
int quicktime_encode_audio(quicktime_t *file, int16_t **input_i, float **input_f, long samples);
int quicktime_dump(quicktime_t *file);
/* Specify the number of cpus to utilize. */
int quicktime_set_cpus(quicktime_t *file, int cpus);
/* Specify whether to read contiguously or not. */
/* preload is the number of bytes to read ahead. */
/* This is no longer functional to the end user but is used to accelerate */
/* reading the header internally. */
void quicktime_set_preload(quicktime_t *file, int64_t preload);
int64_t quicktime_byte_position(quicktime_t *file);
void quicktime_set_avi(quicktime_t *file, int value);
#pragma GCC visibility pop
#ifdef __cplusplus
}
#endif
#endif
quicktime_channel_location
int quicktime_channel_location(quicktime_t *file, int *quicktime_track, int *quicktime_channel, int channel)
quicktime_audio_bits
int quicktime_audio_bits(quicktime_t *file, int track)
Get the bits per sample of an audio track.
quicktime_sample_rate
long quicktime_sample_rate(quicktime_t *file, int track)
Get the samplerate of an audio track.
quicktime_supported_audio
int quicktime_supported_audio(quicktime_t *file, int track)
Check if an audio track is supported by libquicktime.
quicktime_track_channels
int quicktime_track_channels(quicktime_t *file, int track)
Get the number of channels of an audio track.
quicktime_set_audio_position
int quicktime_set_audio_position(quicktime_t *file, int64_t sample, int track)
Seek to a specific audio position.
quicktime_audio_tracks
int quicktime_audio_tracks(quicktime_t *file)
Get the number of audio tracks.
quicktime_audio_length
long quicktime_audio_length(quicktime_t *file, int track)
Get the audio length.
quicktime_audio_compressor
char * quicktime_audio_compressor(quicktime_t *file, int track)
Get the four character code of an audio track.
quicktime_decode_audio
int quicktime_decode_audio(quicktime_t *file, int16_t *output_i, float *output_f, long samples, int channel)
Decode a number of audio samples of a single channel.
quicktime_has_audio
int quicktime_has_audio(quicktime_t *file)
Check if a file has at least one audio track.
quicktime_audio_position
long quicktime_audio_position(quicktime_t *file, int track)
Get the audio position.
quicktime_encode_audio
int quicktime_encode_audio(quicktime_t *file, int16_t **input_i, float **input_f, long samples)
Encode a number of audio samples for the first track.
quicktime_set_audio
int quicktime_set_audio(quicktime_t *file, int channels, long sample_rate, int bits, char *compressor)
Set up tracks in a new file after opening and before writing.
lqt_sample_format_t
lqt_sample_format_t
Sample format definitions for audio.
Definition quicktime.h:288
LQT_SAMPLE_INT8
@ LQT_SAMPLE_INT8
Definition quicktime.h:290
LQT_SAMPLE_INT16
@ LQT_SAMPLE_INT16
Definition quicktime.h:292
LQT_SAMPLE_INT32
@ LQT_SAMPLE_INT32
Definition quicktime.h:293
LQT_SAMPLE_DOUBLE
@ LQT_SAMPLE_DOUBLE
Definition quicktime.h:295
LQT_SAMPLE_FLOAT
@ LQT_SAMPLE_FLOAT
Definition quicktime.h:294
LQT_SAMPLE_UNDEFINED
@ LQT_SAMPLE_UNDEFINED
Definition quicktime.h:289
LQT_SAMPLE_UINT8
@ LQT_SAMPLE_UINT8
Definition quicktime.h:291
quicktime_release
int quicktime_release()
Get the quicktime4linux release number.
quicktime_minor
int quicktime_minor()
Get the quicktime4linux minor version.
quicktime_set_cpus
int quicktime_set_cpus(quicktime_t *file, int cpus)
Set the number of CPUs.
quicktime_open
quicktime_t * quicktime_open(const char *filename, int rd, int wr)
Open a file.
quicktime_major
int quicktime_major()
Get the quicktime4linux major version.
quicktime_set_avi
void quicktime_set_avi(quicktime_t *file, int value)
Write an AVI file instead of quicktime.
quicktime_check_sig
int quicktime_check_sig(char *path)
Test file compatibility.
quicktime_dump
int quicktime_dump(quicktime_t *file)
Dump the file structures to stdout.
quicktime_make_streamable
int quicktime_make_streamable(char *in_path, char *out_path)
Make a file streamable.
quicktime_close
int quicktime_close(quicktime_t *file)
Close a quicktime handle and free all associated memory.
quicktime_t
struct quicktime_s quicktime_t
Quicktime handle.
Definition quicktime.h:306
lqt_log_callback_t
void(* lqt_log_callback_t)(lqt_log_level_t level, const char *domain, const char *message, void *data)
Log callback.
Definition quicktime.h:140
lqt_log_level_t
lqt_log_level_t
Log level.
Definition quicktime.h:125
quicktime_set_copyright
void quicktime_set_copyright(quicktime_t *file, char *string)
Set the copyright info for the file.
quicktime_set_name
void quicktime_set_name(quicktime_t *file, char *string)
Set the name for the file.
quicktime_get_name
char * quicktime_get_name(quicktime_t *file)
Get the name from the file.
quicktime_get_copyright
char * quicktime_get_copyright(quicktime_t *file)
Get the copyright info from the file.
quicktime_set_info
void quicktime_set_info(quicktime_t *file, char *string)
Set info for the file.
quicktime_get_info
char * quicktime_get_info(quicktime_t *file)
Get the info string from the file.
lqt_channel_t
lqt_channel_t
Channel definitions.
Definition quicktime.h:176
quicktime_frame_rate
double quicktime_frame_rate(quicktime_t *file, int track)
Get the framerate of a video track.
quicktime_frame_size
long quicktime_frame_size(quicktime_t *file, long frame, int track)
Get the compressed size of frame in a video track.
quicktime_decode_scaled
long quicktime_decode_scaled(quicktime_t *file, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, int color_model, unsigned char **row_pointers, int track)
Decode aand optionally scale a video frame.
quicktime_video_tracks
int quicktime_video_tracks(quicktime_t *file)
Get the number of video tracks.
quicktime_decode_video
int quicktime_decode_video(quicktime_t *file, unsigned char **row_pointers, int track)
Decode a video frame in BC_RGB888.
quicktime_video_length
long quicktime_video_length(quicktime_t *file, int track)
Get the video length.
quicktime_video_depth
int quicktime_video_depth(quicktime_t *file, int track)
Get the depth of a video track.
quicktime_video_width
int quicktime_video_width(quicktime_t *file, int track)
Get the width of a video track.
quicktime_video_compressor
char * quicktime_video_compressor(quicktime_t *file, int track)
Get the four character code of a video track.
quicktime_video_position
long quicktime_video_position(quicktime_t *file, int track)
Get the video position.
quicktime_has_video
int quicktime_has_video(quicktime_t *file)
Check if a file has at least one video track.
quicktime_video_height
int quicktime_video_height(quicktime_t *file, int track)
Get the height of a video track.
quicktime_supported_video
int quicktime_supported_video(quicktime_t *file, int track)
Check if a video track is supported by libquicktime.
quicktime_reads_cmodel
int quicktime_reads_cmodel(quicktime_t *file, int colormodel, int track)
Check if a colormodel is supported for decoding.
quicktime_set_video_position
int quicktime_set_video_position(quicktime_t *file, int64_t frame, int track)
Seek to a specific video frame.
quicktime_read_frame
long quicktime_read_frame(quicktime_t *file, unsigned char *video_buffer, int track)
Read a compressed video frame.
quicktime_set_depth
void quicktime_set_depth(quicktime_t *file, int depth, int track)
Set the depth of a video track.
quicktime_writes_cmodel
int quicktime_writes_cmodel(quicktime_t *file, int colormodel, int track)
Check if a colormodel is supported for encoding.
quicktime_set_parameter
void quicktime_set_parameter(quicktime_t *file, char *key, void *value)
Set a codec parameter.
quicktime_set_framerate
void quicktime_set_framerate(quicktime_t *file, double framerate)
Set the framerate for encoding.
quicktime_encode_video
int quicktime_encode_video(quicktime_t *file, unsigned char **row_pointers, int track)
Encode a video frame.
quicktime_write_frame
int quicktime_write_frame(quicktime_t *file, uint8_t *video_buffer, int64_t bytes, int track)
Write a compressed video frame.
quicktime_set_video
int quicktime_set_video(quicktime_t *file, int tracks, int frame_w, int frame_h, double frame_rate, char *compressor)
Set up video tracks for encoding.
quicktime_set_jpeg
void quicktime_set_jpeg(quicktime_t *file, int quality, int use_float)
Set jpeg encoding quality.
lqt_chroma_placement_t
lqt_chroma_placement_t
Chroma placement.
Definition quicktime.h:272
quicktime_set_row_span
void quicktime_set_row_span(quicktime_t *file, int row_span)
Set the row_span for en-/decoding.
lqt_interlace_mode_t
lqt_interlace_mode_t
interlace modes
Definition quicktime.h:256
quicktime_set_cmodel
void quicktime_set_cmodel(quicktime_t *file, int colormodel)
Set the colormodel for en-/decoding.
LQT_CHROMA_PLACEMENT_DVPAL
@ LQT_CHROMA_PLACEMENT_DVPAL
Definition quicktime.h:275
LQT_CHROMA_PLACEMENT_DEFAULT
@ LQT_CHROMA_PLACEMENT_DEFAULT
Definition quicktime.h:273
LQT_CHROMA_PLACEMENT_MPEG2
@ LQT_CHROMA_PLACEMENT_MPEG2
Definition quicktime.h:274
LQT_INTERLACE_TOP_FIRST
@ LQT_INTERLACE_TOP_FIRST
Definition quicktime.h:258
LQT_INTERLACE_NONE
@ LQT_INTERLACE_NONE
Definition quicktime.h:257
LQT_INTERLACE_BOTTOM_FIRST
@ LQT_INTERLACE_BOTTOM_FIRST
Definition quicktime.h:259
lqt_file_type_t
lqt_file_type_t
File types.
Definition quicktime.h:153
LQT_FILE_QT_OLD
@ LQT_FILE_QT_OLD
Definition quicktime.h:155
LQT_FILE_MP4
@ LQT_FILE_MP4
Definition quicktime.h:159
LQT_FILE_3GP
@ LQT_FILE_3GP
Definition quicktime.h:161
LQT_FILE_M4A
@ LQT_FILE_M4A
Definition quicktime.h:160
LQT_FILE_AVI_ODML
@ LQT_FILE_AVI_ODML
Definition quicktime.h:158
LQT_FILE_NONE
@ LQT_FILE_NONE
Definition quicktime.h:154
LQT_FILE_AVI
@ LQT_FILE_AVI
Definition quicktime.h:157
LQT_FILE_QT
@ LQT_FILE_QT
Definition quicktime.h:156
quicktime_seek_start
int quicktime_seek_start(quicktime_t *file)
Reposition all tracks to the very beginning.
lqt_codec_info_s
Structure describing a codec.
Definition lqt_codecinfo.h:188