| 1 |
/***************************************************************************** |
|---|
| 2 |
* |
|---|
| 3 |
* Avi Import Component Private Header |
|---|
| 4 |
* |
|---|
| 5 |
* Copyright(C) 2006 Christoph Naegeli <chn1@mac.com> |
|---|
| 6 |
* |
|---|
| 7 |
* This library 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 |
* This library 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 this library; if not, write to the Free Software |
|---|
| 19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 20 |
* |
|---|
| 21 |
****************************************************************************/ |
|---|
| 22 |
|
|---|
| 23 |
#ifndef __FF_PRIVATE__ |
|---|
| 24 |
#define __FF_PRIVATE__ |
|---|
| 25 |
|
|---|
| 26 |
#include "avformat.h" |
|---|
| 27 |
#include <QuickTime/Movies.h> |
|---|
| 28 |
|
|---|
| 29 |
/* Data structres needed for import */ |
|---|
| 30 |
struct _NCStream { |
|---|
| 31 |
int index; |
|---|
| 32 |
AVStream *str; |
|---|
| 33 |
SampleDescriptionHandle sampleHdl; |
|---|
| 34 |
AudioStreamBasicDescription asbd; |
|---|
| 35 |
Media media; |
|---|
| 36 |
UInt32 vbr; |
|---|
| 37 |
AVRational base; |
|---|
| 38 |
int64_t lastpts; |
|---|
| 39 |
SampleReference64Ptr sampleTable; |
|---|
| 40 |
SampleReference64Record lastSample; |
|---|
| 41 |
TimeValue duration; |
|---|
| 42 |
}; |
|---|
| 43 |
typedef struct _NCStream NCStream; |
|---|
| 44 |
|
|---|
| 45 |
// this used to live in ff_MovieImport.c, but it had to move here for idling support |
|---|
| 46 |
struct _ff_global_context { |
|---|
| 47 |
Movie movie; |
|---|
| 48 |
ComponentInstance ci; |
|---|
| 49 |
OSType componentType; |
|---|
| 50 |
|
|---|
| 51 |
/* For feedback during import */ |
|---|
| 52 |
MovieProgressUPP prog; |
|---|
| 53 |
long refcon; |
|---|
| 54 |
|
|---|
| 55 |
/* for overwriting the default sample descriptions */ |
|---|
| 56 |
ImageDescriptionHandle imgHdl; |
|---|
| 57 |
SoundDescriptionHandle sndHdl; |
|---|
| 58 |
|
|---|
| 59 |
// things needed for idling support |
|---|
| 60 |
Track placeholderTrack; |
|---|
| 61 |
DataHandler dataHandler; |
|---|
| 62 |
bool isStreamed; |
|---|
| 63 |
Boolean dataHandlerSupportsWideOffsets; |
|---|
| 64 |
int64_t dataSize; |
|---|
| 65 |
int largestPacketSize; |
|---|
| 66 |
|
|---|
| 67 |
IdleManager idleManager; |
|---|
| 68 |
long movieLoadState; |
|---|
| 69 |
TimeValue loadedTime; |
|---|
| 70 |
TimeValue lastIdleTime; |
|---|
| 71 |
int idlesSinceLastAdd; |
|---|
| 72 |
|
|---|
| 73 |
//the "atTime" parameter to the initial import. |
|---|
| 74 |
TimeValue atTime; |
|---|
| 75 |
|
|---|
| 76 |
// libavcodec fun. |
|---|
| 77 |
AVInputFormat *format; |
|---|
| 78 |
AVFormatContext *format_context; |
|---|
| 79 |
NCStream *stream_map; |
|---|
| 80 |
int map_count; |
|---|
| 81 |
int64_t header_offset; |
|---|
| 82 |
|
|---|
| 83 |
AVPacket firstFrames[MAX_STREAMS]; |
|---|
| 84 |
}; |
|---|
| 85 |
typedef struct _ff_global_context ff_global_context; |
|---|
| 86 |
typedef ff_global_context *ff_global_ptr; |
|---|
| 87 |
|
|---|
| 88 |
/* Utilities */ |
|---|
| 89 |
ComponentResult check_system(); |
|---|
| 90 |
|
|---|
| 91 |
/* Library initialization */ |
|---|
| 92 |
void register_parsers(); |
|---|
| 93 |
|
|---|
| 94 |
/* Public interface of the DataRef interface */ |
|---|
| 95 |
OSStatus url_open_dataref(ByteIOContext *pb, Handle dataRef, OSType dataRefType, DataHandler *dataHandler, Boolean *wideSupport, int64_t *dataSize); |
|---|
| 96 |
|
|---|
| 97 |
/* Import routines */ |
|---|
| 98 |
int prepare_track(ff_global_ptr storage, Track targetTrack, Handle dataRef, OSType dataRefType); |
|---|
| 99 |
int prepare_movie(ff_global_ptr storage, Movie theMovie, Handle dataRef, OSType dataRefType); |
|---|
| 100 |
void initialize_video_map(NCStream *map, Track targetTrack, Handle dataRef, OSType dataRefType, AVPacket *firstFrame); |
|---|
| 101 |
void initialize_audio_map(NCStream *map, Track targetTrack, Handle dataRef, OSType dataRefType, AVPacket *firstFrame); |
|---|
| 102 |
|
|---|
| 103 |
int determine_header_offset(ff_global_ptr storage); |
|---|
| 104 |
int import_using_index(ff_global_ptr storage, int *hadIndex, TimeValue *addedDuration); |
|---|
| 105 |
ComponentResult import_with_idle(ff_global_ptr storage, long inFlags, long *outFlags, int minFrames, int maxFrames, bool addSamples); |
|---|
| 106 |
ComponentResult create_placeholder_track(Movie movie, Track *placeholderTrack, TimeValue duration, Handle dataRef, OSType dataRefType); |
|---|
| 107 |
void send_movie_changed_notification(Movie movie); |
|---|
| 108 |
|
|---|
| 109 |
OSType map_video_codec_to_mov_tag(enum CodecID codec_id); |
|---|
| 110 |
void map_avi_to_mov_tag(enum CodecID codec_id, AudioStreamBasicDescription *asbd, NCStream *map); |
|---|
| 111 |
uint8_t *create_cookie(AVCodecContext *codec, int *cookieSize, UInt32 formatID); |
|---|
| 112 |
Handle create_strf_ext(AVCodecContext *codec); |
|---|
| 113 |
|
|---|
| 114 |
uint8_t *write_int32(uint8_t *target, int32_t data); |
|---|
| 115 |
uint8_t *write_int16(uint8_t *target, int16_t data); |
|---|
| 116 |
uint8_t *write_data(uint8_t *target, uint8_t* data, int32_t data_size); |
|---|
| 117 |
|
|---|
| 118 |
#define BSWAP(a) ( (((a)&0xff) << 24) | (((a)&0xff00) << 8) | (((a)&0xff0000) >> 8) | (((a) >> 24) & 0xff) ) |
|---|
| 119 |
|
|---|
| 120 |
#define IS_AVI(x) (x == 'AVI ' || x == 'VfW ' || x == 'VFW ') |
|---|
| 121 |
|
|---|
| 122 |
#endif |
|---|