Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line | 
|---|---|---|---|
| 1 | pmbaty | 1 | /** | 
| 2 |         libsmacker - A C library for decoding .smk Smacker Video files | ||
| 3 |         Copyright (C) 2012-2020 Greg Kennedy | ||
| 4 | |||
| 5 |         libsmacker is a cross-platform C library which can be used for | ||
| 6 |         decoding Smacker Video files produced by RAD Game Tools. | ||
| 7 | |||
| 8 |         This program is free software: you can redistribute it and/or modify | ||
| 9 |         it under the terms of the GNU Lesser General Public License as published by | ||
| 10 |         the Free Software Foundation, either version 2.1 of the License, or | ||
| 11 |         (at your option) any later version. | ||
| 12 | |||
| 13 |         This program is distributed in the hope that it will be useful, | ||
| 14 |         but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 |         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||
| 16 |         GNU Lesser General Public License for more details. | ||
| 17 | |||
| 18 |         You should have received a copy of the GNU Lesser General Public License | ||
| 19 |         along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #ifndef SMACKER_H | ||
| 23 | #define SMACKER_H | ||
| 24 | |||
| 25 | /* includes - needed for FILE* here */ | ||
| 26 | #include <stdio.h> | ||
| 27 | |||
| 28 | /** forward-declaration for an struct */ | ||
| 29 | typedef struct smk_t* smk; | ||
| 30 | |||
| 31 | /** a few defines as return codes from smk_next() */ | ||
| 32 | #define SMK_DONE        0x00 | ||
| 33 | #define SMK_MORE        0x01 | ||
| 34 | #define SMK_LAST        0x02 | ||
| 35 | #define SMK_ERROR       -1 | ||
| 36 | |||
| 37 | /** file-processing mode, pass to smk_open_file */ | ||
| 38 | #define SMK_MODE_DISK   0x00 | ||
| 39 | #define SMK_MODE_MEMORY 0x01 | ||
| 40 | |||
| 41 | /** Y-scale meanings */ | ||
| 42 | #define SMK_FLAG_Y_NONE 0x00 | ||
| 43 | #define SMK_FLAG_Y_INTERLACE    0x01 | ||
| 44 | #define SMK_FLAG_Y_DOUBLE       0x02 | ||
| 45 | |||
| 46 | /** track mask and enable bits */ | ||
| 47 | #define SMK_AUDIO_TRACK_0       0x01 | ||
| 48 | #define SMK_AUDIO_TRACK_1       0x02 | ||
| 49 | #define SMK_AUDIO_TRACK_2       0x04 | ||
| 50 | #define SMK_AUDIO_TRACK_3       0x08 | ||
| 51 | #define SMK_AUDIO_TRACK_4       0x10 | ||
| 52 | #define SMK_AUDIO_TRACK_5       0x20 | ||
| 53 | #define SMK_AUDIO_TRACK_6       0x40 | ||
| 54 | #define SMK_VIDEO_TRACK 0x80 | ||
| 55 | |||
| 56 | /* PUBLIC FUNCTIONS */ | ||
| 57 | #ifdef __cplusplus | ||
| 58 | extern "C" { | ||
| 59 | #endif | ||
| 60 | |||
| 61 | /* OPEN OPERATIONS */ | ||
| 62 | /** open an smk (from a file) */ | ||
| 63 | smk smk_open_file(const char* filename, unsigned char mode); | ||
| 64 | /** open an smk (from a file pointer) */ | ||
| 65 | smk smk_open_filepointer(FILE* file, unsigned char mode); | ||
| 66 | /** read an smk (from a memory buffer) */ | ||
| 67 | smk smk_open_memory(const unsigned char* buffer, unsigned long size); | ||
| 68 | |||
| 69 | /* CLOSE OPERATIONS */ | ||
| 70 | /** close out an smk file and clean up memory */ | ||
| 71 | void smk_close(smk object); | ||
| 72 | |||
| 73 | /* GET FILE INFO OPERATIONS */ | ||
| 74 | char smk_info_all(const smk object, unsigned long* frame, unsigned long* frame_count, double* usf); | ||
| 75 | char smk_info_video(const smk object, unsigned long* w, unsigned long* h, unsigned char* y_scale_mode); | ||
| 76 | char smk_info_audio(const smk object, unsigned char* track_mask, unsigned char channels[7], unsigned char bitdepth[7], unsigned long audio_rate[7]); | ||
| 77 | |||
| 78 | /* ENABLE/DISABLE Switches */ | ||
| 79 | char smk_enable_all(smk object, unsigned char mask); | ||
| 80 | char smk_enable_video(smk object, unsigned char enable); | ||
| 81 | char smk_enable_audio(smk object, unsigned char track, unsigned char enable); | ||
| 82 | |||
| 83 | /** Retrieve palette */ | ||
| 84 | const unsigned char* smk_get_palette(const smk object); | ||
| 85 | /** Retrieve video frame, as a buffer of size w*h */ | ||
| 86 | const unsigned char* smk_get_video(const smk object); | ||
| 87 | /** Retrieve decoded audio chunk, track N */ | ||
| 88 | const unsigned char* smk_get_audio(const smk object, unsigned char track); | ||
| 89 | /** Get size of currently pointed decoded audio chunk, track N */ | ||
| 90 | unsigned long smk_get_audio_size(const smk object, unsigned char track); | ||
| 91 | |||
| 92 | /** rewind to first frame and unpack */ | ||
| 93 | char smk_first(smk object); | ||
| 94 | /** advance to next frame and unpack */ | ||
| 95 | char smk_next(smk object); | ||
| 96 | /** seek to first keyframe before/at N in an smk */ | ||
| 97 | char smk_seek_keyframe(smk object, unsigned long frame); | ||
| 98 | |||
| 99 | #ifdef __cplusplus | ||
| 100 | } | ||
| 101 | #endif | ||
| 102 | |||
| 103 | #endif |