123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- #ifndef _NSVLIB_H_
- #define _NSVLIB_H_
- #include "nsvbs.h"
- #define NSV_MAX_AUDIO_LEN 0x8000
- #define NSV_MAX_VIDEO_LEN 0x80000
- #define NSV_MAX_AUX_LEN 0x8000
- #define NSV_MAX_AUXSTREAMS 15
- #define METADATANAME_AUTHOR "Author"
- #define METADATANAME_TITLE "Title"
- #define METADATANAME_COPYRIGHT "Copyright"
- #define METADATANAME_COMMENT "Comment"
- #define METADATANAME_PROFILE "Profile"
- #define METADATANAME_FILEID "File ID"
- #define NSV_MAKETYPE(A,B,C,D) ((A) | ((B)<<8) | ((C)<<16) | ((D)<<24))
- void nsv_type_to_string(unsigned int t, char *out);
- unsigned int nsv_string_to_type(char *in);
- class nsv_Packeter {
- public:
- nsv_Packeter();
- ~nsv_Packeter();
-
- void setVidFmt(unsigned int vfmt, unsigned int w, unsigned int h, double frt);
- void setAudFmt(unsigned int afmt) { audfmt=afmt; }
-
- void setSyncFrame(int is_syncframe) { is_sync_frame=is_syncframe; }
- void setSyncOffset(int syncoffs) { syncoffset_cur=syncoffs; }
- void setAudio(void *a, int a_len) { audio=a; audio_len=a_len; }
- void setVideo(void *v, int v_len) { video=v; video_len=v_len; }
- int addAuxChannel(unsigned int fmt, void *data, int data_len)
- {
- if (aux_used >= NSV_MAX_AUXSTREAMS) return -1;
- aux[aux_used]=data;
- aux_len[aux_used]=data_len;
- aux_types[aux_used]=fmt;
- aux_used++;
- return 0;
- }
- void clearAuxChannels() { aux_used=0; }
- int packet(nsv_OutBS &bs);
-
- unsigned int getAudFmt() { return audfmt; }
- unsigned int getVidFmt() { return vidfmt; }
- unsigned int getWidth() { return width; }
- unsigned int getHeight() { return height; }
- double getFrameRate() { return framerate; }
- private:
- unsigned char framerate_idx;
- unsigned int vidfmt;
- unsigned int audfmt;
- unsigned int width;
- unsigned int height;
- double framerate;
- int syncoffset_cur;
- int aux_used;
- void *aux[NSV_MAX_AUXSTREAMS];
- int aux_len[NSV_MAX_AUXSTREAMS];
- unsigned int aux_types[NSV_MAX_AUXSTREAMS];
- int is_sync_frame;
- void *audio;
- int audio_len;
- void *video;
- int video_len;
- };
- class nsv_Unpacketer {
- public:
- nsv_Unpacketer() { reset(); }
- ~nsv_Unpacketer() { }
- void reset(int full=1);
-
-
-
-
- void setEof(int eof=1) { m_eof=eof; }
- int getEof() { return m_eof; }
-
-
-
- void setAudioOut(nsv_InBS *output=NULL) { m_audiobs=output; }
-
-
-
-
-
-
-
- void setVideoOut(nsv_InBS *output=NULL) { m_videobs=output; }
-
-
-
-
-
-
-
- void setAuxOut(nsv_InBS *output=NULL) { m_auxbs=output; }
-
-
-
-
-
-
-
-
-
-
-
-
-
- int unpacket(nsv_InBS &bs);
-
- int isValid() { return valid; }
-
-
- int isSynched() { return synched; }
-
- signed int getSyncOffset() { return (signed int) syncoffset; }
-
- signed int getCurSyncOffset() { return (signed int) syncoffset_cur; }
-
- unsigned int getVidFmt() { return vidfmt; }
- unsigned int getAudFmt() { return audfmt; }
- unsigned int getWidth() { return width; }
- unsigned int getHeight() { return height; }
- double getFrameRate() { return framerate; }
- unsigned char getFrameRateIdx() { return framerate_idx; }
-
- int isSynchFrame() { return is_sync_frame; }
- private:
- nsv_InBS *m_audiobs, *m_videobs, *m_auxbs;
- int valid;
- int synched;
- unsigned int vidfmt;
- unsigned int audfmt;
- unsigned int width;
- unsigned int height;
- double framerate;
- int is_sync_frame;
- unsigned char framerate_idx;
- int syncoffset;
- int syncoffset_cur;
- int m_eof;
- };
- typedef struct {
-
-
- unsigned int header_size;
-
-
- unsigned int file_lenbytes;
-
-
- unsigned int file_lenms;
-
- unsigned int metadata_len;
-
-
- unsigned int toc_alloc;
-
-
-
-
- unsigned int toc_size;
-
-
-
- unsigned int *toc;
-
-
-
-
-
- unsigned int *toc_ex;
-
-
-
- void *metadata;
- } nsv_fileHeader;
- void nsv_writeheader(nsv_OutBS &bs, nsv_fileHeader *hdr, unsigned int padto);
- int nsv_readheader(nsv_InBS &bs, nsv_fileHeader *hdr);
- char *nsv_getmetadata(void *metadata, char *name);
- #endif
|