2009-04-06 21:14:55 +02:00
|
|
|
// Copyright (c) 2007-2009 Fredrik Mellbin
|
2008-09-01 23:16:13 +02:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
#ifndef FFMS_H
|
|
|
|
#define FFMS_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2008-09-12 22:41:29 +02:00
|
|
|
# define EXTERN_C extern "C"
|
2008-09-01 23:16:13 +02:00
|
|
|
#else
|
2008-09-12 22:41:29 +02:00
|
|
|
# define EXTERN_C
|
2008-09-01 23:16:13 +02:00
|
|
|
#endif
|
|
|
|
|
2008-09-23 16:58:39 +02:00
|
|
|
#ifdef _WIN32
|
2008-09-12 22:41:29 +02:00
|
|
|
# define FFMS_CC __stdcall
|
|
|
|
# ifdef FFMS_EXPORTS
|
|
|
|
# define FFMS_API(ret) EXTERN_C __declspec(dllexport) ret FFMS_CC
|
|
|
|
# else
|
|
|
|
# define FFMS_API(ret) EXTERN_C __declspec(dllimport) ret FFMS_CC
|
|
|
|
# endif
|
2008-09-01 23:16:13 +02:00
|
|
|
#else
|
2008-09-23 16:58:39 +02:00
|
|
|
# define FFMS_CC
|
2008-09-12 22:41:29 +02:00
|
|
|
# define FFMS_API(ret) EXTERN_C ret FFMS_CC
|
2008-09-01 23:16:13 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
class VideoBase;
|
2008-09-19 23:35:46 +02:00
|
|
|
class AudioBase;
|
2008-09-01 23:16:13 +02:00
|
|
|
class FrameIndex;
|
|
|
|
class FrameInfoVector;
|
|
|
|
|
2008-09-04 23:40:57 +02:00
|
|
|
typedef int (FFMS_CC *IndexCallback)(int State, int64_t Current, int64_t Total, void *Private);
|
2008-09-02 21:48:22 +02:00
|
|
|
|
2009-04-11 20:45:40 +02:00
|
|
|
enum FFMS_SeekMode {
|
|
|
|
FFMS_SEEK_LINEAR_NO_RW = -1,
|
|
|
|
FFMS_SEEK_LINEAR = 0,
|
|
|
|
FFMS_SEEK_NORMAL = 1,
|
|
|
|
FFMS_SEEK_UNSAFE = 2,
|
|
|
|
FFMS_SEEK_AGGRESSIVE = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum FFMS_TrackType {
|
2008-09-23 23:56:30 +02:00
|
|
|
FFMS_TYPE_VIDEO = 0,
|
|
|
|
FFMS_TYPE_AUDIO = 1,
|
|
|
|
};
|
|
|
|
|
2008-09-01 23:16:13 +02:00
|
|
|
// This is a subset of the original AVFrame only containing the most used parts.
|
|
|
|
// Even if it might seem like a good idea to cast it back to a full AVFrame to
|
|
|
|
// access a few more values you really shouldn't do that. Only the values present
|
|
|
|
// in AVFrameLite are actually updated when postprocessing is used.
|
|
|
|
|
|
|
|
struct AVFrameLite {
|
|
|
|
uint8_t *Data[4];
|
|
|
|
int Linesize[4];
|
|
|
|
uint8_t *Base[4];
|
|
|
|
int KeyFrame;
|
|
|
|
int PictType;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TrackTimeBase {
|
2009-04-06 21:14:55 +02:00
|
|
|
int64_t Num;
|
|
|
|
int64_t Den;
|
2008-09-01 23:16:13 +02:00
|
|
|
};
|
|
|
|
|
2008-09-12 22:41:29 +02:00
|
|
|
class FrameInfo {
|
|
|
|
public:
|
2008-09-27 03:21:57 +02:00
|
|
|
int64_t DTS;
|
|
|
|
int64_t SampleStart;
|
2008-09-19 23:35:46 +02:00
|
|
|
int64_t FilePos;
|
|
|
|
unsigned int FrameSize;
|
2008-09-01 23:16:13 +02:00
|
|
|
bool KeyFrame;
|
|
|
|
FrameInfo(int64_t DTS, bool KeyFrame);
|
2008-09-27 03:21:57 +02:00
|
|
|
FrameInfo(int64_t DTS, int64_t SampleStart, bool KeyFrame);
|
2008-09-19 23:35:46 +02:00
|
|
|
FrameInfo(int64_t SampleStart, int64_t FilePos, unsigned int FrameSize, bool KeyFrame);
|
2008-09-01 23:16:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct VideoProperties {
|
|
|
|
int Width;
|
|
|
|
int Height;
|
|
|
|
int FPSDenominator;
|
|
|
|
int FPSNumerator;
|
|
|
|
int NumFrames;
|
2009-04-25 11:09:14 +02:00
|
|
|
int VPixelFormat;
|
2008-09-01 23:16:13 +02:00
|
|
|
int SARNum;
|
|
|
|
int SARDen;
|
|
|
|
int CropTop;
|
|
|
|
int CropBottom;
|
|
|
|
int CropLeft;
|
|
|
|
int CropRight;
|
2008-09-27 21:05:10 +02:00
|
|
|
double FirstTime;
|
|
|
|
double LastTime;
|
2008-09-01 23:16:13 +02:00
|
|
|
};
|
|
|
|
|
2008-09-19 23:35:46 +02:00
|
|
|
struct AudioProperties {
|
|
|
|
int SampleRate;
|
|
|
|
int Channels;
|
|
|
|
int BitsPerSample;
|
|
|
|
bool Float;
|
|
|
|
int64_t NumSamples;
|
|
|
|
};
|
|
|
|
|
2008-10-01 20:13:12 +02:00
|
|
|
// Most functions return 0 on success
|
|
|
|
// Functions without error message output can be assumed to never fail
|
2008-09-02 01:18:50 +02:00
|
|
|
FFMS_API(void) FFMS_Init();
|
2009-01-03 16:17:53 +01:00
|
|
|
FFMS_API(void) FFMS_NoLog();
|
2008-09-01 23:16:13 +02:00
|
|
|
FFMS_API(VideoBase *) FFMS_CreateVideoSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, const char *PP, int Threads, int SeekMode, char *ErrorMsg, unsigned MsgSize);
|
2008-09-19 23:35:46 +02:00
|
|
|
FFMS_API(AudioBase *) FFMS_CreateAudioSource(const char *SourceFile, int Track, FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize);
|
2008-09-01 23:16:13 +02:00
|
|
|
FFMS_API(void) FFMS_DestroyVideoSource(VideoBase *VB);
|
2008-09-19 23:35:46 +02:00
|
|
|
FFMS_API(void) FFMS_DestroyAudioSource(AudioBase *AB);
|
2008-09-01 23:16:13 +02:00
|
|
|
FFMS_API(const VideoProperties *) FFMS_GetVideoProperties(VideoBase *VB);
|
2008-09-19 23:35:46 +02:00
|
|
|
FFMS_API(const AudioProperties *) FFMS_GetAudioProperties(AudioBase *AB);
|
2008-09-01 23:16:13 +02:00
|
|
|
FFMS_API(const AVFrameLite *) FFMS_GetFrame(VideoBase *VB, int n, char *ErrorMsg, unsigned MsgSize);
|
2008-09-27 03:21:57 +02:00
|
|
|
FFMS_API(const AVFrameLite *) FFMS_GetFrameByTime(VideoBase *VB, double Time, char *ErrorMsg, unsigned MsgSize);
|
2008-09-19 23:35:46 +02:00
|
|
|
FFMS_API(int) FFMS_GetAudio(AudioBase *AB, void *Buf, int64_t Start, int64_t Count, char *ErrorMsg, unsigned MsgSize);
|
2008-10-01 20:13:12 +02:00
|
|
|
FFMS_API(int) FFMS_SetOutputFormat(VideoBase *VB, int TargetFormat, int Width, int Height, char *ErrorMsg, unsigned MsgSize);
|
2008-09-09 22:49:59 +02:00
|
|
|
FFMS_API(void) FFMS_ResetOutputFormat(VideoBase *VB);
|
2008-09-01 23:16:13 +02:00
|
|
|
FFMS_API(void) FFMS_DestroyFrameIndex(FrameIndex *FI);
|
2008-09-27 21:05:10 +02:00
|
|
|
FFMS_API(int) FFMS_GetFirstTrackOfType(FrameIndex *TrackIndices, int TrackType, char *ErrorMsg, unsigned MsgSize);
|
2008-10-01 20:13:12 +02:00
|
|
|
FFMS_API(int) FFMS_GetNumTracks(FrameIndex *TrackIndices);
|
|
|
|
FFMS_API(int) FFMS_GetTrackType(FrameInfoVector *FIV);
|
|
|
|
FFMS_API(int) FFMS_GetNumFrames(FrameInfoVector *FIV);
|
2008-09-01 23:16:13 +02:00
|
|
|
FFMS_API(const FrameInfo *) FFMS_GetFrameInfo(FrameInfoVector *FIV, int Frame, char *ErrorMsg, unsigned MsgSize);
|
|
|
|
FFMS_API(FrameInfoVector *) FFMS_GetTITrackIndex(FrameIndex *TrackIndices, int Track, char *ErrorMsg, unsigned MsgSize);
|
2008-10-01 20:13:12 +02:00
|
|
|
FFMS_API(FrameInfoVector *) FFMS_GetVSTrackIndex(VideoBase *VB);
|
|
|
|
FFMS_API(FrameInfoVector *) FFMS_GetASTrackIndex(AudioBase *AB);
|
2008-09-01 23:16:13 +02:00
|
|
|
FFMS_API(int) FFMS_FindClosestKeyFrame(FrameInfoVector *FIV, int Frame, char *ErrorMsg, unsigned MsgSize);
|
2008-10-01 20:13:12 +02:00
|
|
|
FFMS_API(const TrackTimeBase *) FFMS_GetTimeBase(FrameInfoVector *FIV);
|
2008-09-01 23:16:13 +02:00
|
|
|
FFMS_API(int) FFMS_WriteTimecodes(FrameInfoVector *FIV, const char *TimecodeFile, char *ErrorMsg, unsigned MsgSize);
|
2008-09-24 16:11:45 +02:00
|
|
|
FFMS_API(FrameIndex *) FFMS_MakeIndex(const char *SourceFile, int IndexMask, int DumpMask, const char *AudioFile, bool IgnoreDecodeErrors, IndexCallback IP, void *Private, char *ErrorMsg, unsigned MsgSize);
|
2008-09-04 00:26:27 +02:00
|
|
|
FFMS_API(FrameIndex *) FFMS_ReadIndex(const char *IndexFile, char *ErrorMsg, unsigned MsgSize);
|
2008-09-01 23:16:13 +02:00
|
|
|
FFMS_API(int) FFMS_WriteIndex(const char *IndexFile, FrameIndex *TrackIndices, char *ErrorMsg, unsigned MsgSize);
|
2009-04-25 10:55:14 +02:00
|
|
|
FFMS_API(int) FFMS_GetPixFmt(const char *Name);
|
2008-09-01 23:16:13 +02:00
|
|
|
#endif
|