update nestegg, support vp9
This commit is contained in:
parent
feb469d863
commit
142e478c51
4 changed files with 907 additions and 142 deletions
|
|
@ -4,12 +4,12 @@
|
|||
* This program is made available under an ISC-style license. See the
|
||||
* accompanying file LICENSE for details.
|
||||
*/
|
||||
#ifndef NESTEGG_671cac2a_365d_ed69_d7a3_4491d3538d79
|
||||
#define NESTEGG_671cac2a_365d_ed69_d7a3_4491d3538d79
|
||||
#if !defined(NESTEGG_671cac2a_365d_ed69_d7a3_4491d3538d79)
|
||||
#define NESTEGG_671cac2a_365d_ed69_d7a3_4491d3538d79
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
|
@ -67,6 +67,8 @@ extern "C" {
|
|||
|
||||
#define NESTEGG_CODEC_VP8 0 /**< Track uses Google On2 VP8 codec. */
|
||||
#define NESTEGG_CODEC_VORBIS 1 /**< Track uses Xiph Vorbis codec. */
|
||||
#define NESTEGG_CODEC_VP9 2 /**< Track uses Google On2 VP9 codec. */
|
||||
#define NESTEGG_CODEC_OPUS 3 /**< Track uses Xiph Opus codec. */
|
||||
|
||||
#define NESTEGG_VIDEO_MONO 0 /**< Track is mono video. */
|
||||
#define NESTEGG_VIDEO_STEREO_LEFT_RIGHT 1 /**< Track is side-by-side stereo video. Left first. */
|
||||
|
|
@ -131,6 +133,7 @@ typedef struct {
|
|||
unsigned int crop_top; /**< Pixels to crop from the top of the frame. */
|
||||
unsigned int crop_left; /**< Pixels to crop from the left of the frame. */
|
||||
unsigned int crop_right; /**< Pixels to crop from the right of the frame. */
|
||||
unsigned int alpha_mode; /**< 1 if an additional opacity stream is available, otherwise 0. */
|
||||
} nestegg_video_params;
|
||||
|
||||
/** Parameters specific to an audio track. */
|
||||
|
|
@ -138,6 +141,8 @@ typedef struct {
|
|||
double rate; /**< Sampling rate in Hz. */
|
||||
unsigned int channels; /**< Number of audio channels. */
|
||||
unsigned int depth; /**< Bits per sample. */
|
||||
uint64_t codec_delay; /**< Nanoseconds that must be discarded from the start. */
|
||||
uint64_t seek_preroll;/**< Nanoseconds that must be discarded after a seek. */
|
||||
} nestegg_audio_params;
|
||||
|
||||
/** Logging callback function pointer. */
|
||||
|
|
@ -149,9 +154,10 @@ typedef void (* nestegg_log)(nestegg * context, unsigned int severity, char cons
|
|||
@param context Storage for the new nestegg context. @see nestegg_destroy
|
||||
@param io User supplied IO context.
|
||||
@param callback Optional logging callback function pointer. May be NULL.
|
||||
@param max_offset Optional maximum offset to be read. Set -1 to ignore.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_init(nestegg ** context, nestegg_io io, nestegg_log callback);
|
||||
int nestegg_init(nestegg ** context, nestegg_io io, nestegg_log callback, int64_t max_offset);
|
||||
|
||||
/** Destroy a nestegg context and free associated memory.
|
||||
@param context #nestegg context to be freed. @see nestegg_init */
|
||||
|
|
@ -180,6 +186,29 @@ int nestegg_tstamp_scale(nestegg * context, uint64_t * scale);
|
|||
@retval -1 Error. */
|
||||
int nestegg_track_count(nestegg * context, unsigned int * tracks);
|
||||
|
||||
/** Query the start and end offset for a particular cluster.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param cluster_num Zero-based cluster number; order they appear in cues.
|
||||
@param max_offset Optional maximum offset to be read. Set -1 to ignore.
|
||||
@param start_pos Starting offset of the cluster. -1 means non-existant.
|
||||
@param end_pos Starting offset of the cluster. -1 means non-existant or
|
||||
final cluster.
|
||||
@param tstamp Starting timestamp of the cluster.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_get_cue_point(nestegg * context, unsigned int cluster_num,
|
||||
int64_t max_offset, int64_t * start_pos,
|
||||
int64_t * end_pos, uint64_t * tstamp);
|
||||
|
||||
/** Seek to @a offset. Stream will seek directly to offset.
|
||||
Should be used to seek to the start of a resync point, i.e. cluster; the
|
||||
parser will not be able to understand other offsets.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param offset Absolute offset in bytes.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_offset_seek(nestegg * context, uint64_t offset);
|
||||
|
||||
/** Seek @a track to @a tstamp. Stream seek will terminate at the earliest
|
||||
key point in the stream at or before @a tstamp. Other tracks in the
|
||||
stream will output packets with unspecified but nearby timestamps.
|
||||
|
|
@ -248,6 +277,16 @@ int nestegg_track_video_params(nestegg * context, unsigned int track,
|
|||
int nestegg_track_audio_params(nestegg * context, unsigned int track,
|
||||
nestegg_audio_params * params);
|
||||
|
||||
/** Query the default frame duration for @a track. For a video track, this
|
||||
is typically the inverse of the video frame rate.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@param track Zero based track number.
|
||||
@param duration Storage for the default duration in nanoseconds.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_track_default_duration(nestegg * context, unsigned int track,
|
||||
uint64_t * duration);
|
||||
|
||||
/** Read a packet of media data. A packet consists of one or more chunks of
|
||||
data associated with a single track. nestegg_read_packet should be
|
||||
called in a loop while the return value is 1 to drive the stream parser
|
||||
|
|
@ -277,6 +316,13 @@ int nestegg_packet_track(nestegg_packet * packet, unsigned int * track);
|
|||
@retval -1 Error. */
|
||||
int nestegg_packet_tstamp(nestegg_packet * packet, uint64_t * tstamp);
|
||||
|
||||
/** Query the duration in nanoseconds of @a packet.
|
||||
@param packet Packet initialized by #nestegg_read_packet.
|
||||
@param duration Storage for the queried duration in nanoseconds.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_packet_duration(nestegg_packet * packet, uint64_t * duration);
|
||||
|
||||
/** Query the number of data chunks contained in @a packet.
|
||||
@param packet Packet initialized by #nestegg_read_packet.
|
||||
@param count Storage for the queried timestamp in nanoseconds.
|
||||
|
|
@ -295,7 +341,50 @@ int nestegg_packet_count(nestegg_packet * packet, unsigned int * count);
|
|||
int nestegg_packet_data(nestegg_packet * packet, unsigned int item,
|
||||
unsigned char ** data, size_t * length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
/** Get a pointer to additional data with identifier @a id of additional packet
|
||||
data. If @a id isn't present in the packet, returns -1.
|
||||
@param packet Packet initialized by #nestegg_read_packet.
|
||||
@param id Codec specific identifer. For VP8, use 1 to get a VP8 encoded
|
||||
frame containing an alpha channel in its Y plane.
|
||||
@param data Storage for the queried data pointer.
|
||||
The data is owned by the #nestegg_packet packet.
|
||||
@param length Storage for the queried data size.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_packet_additional_data(nestegg_packet * packet, unsigned int id,
|
||||
unsigned char ** data, size_t * length);
|
||||
|
||||
/** Returns discard_padding for given packet
|
||||
@param packet Packet initialized by #nestegg_read_packet.
|
||||
@param discard_padding pointer to store discard padding in.
|
||||
@retval 0 Success.
|
||||
@retval -1 Error. */
|
||||
int nestegg_packet_discard_padding(nestegg_packet * packet,
|
||||
int64_t * discard_padding);
|
||||
|
||||
/** Query the presence of cues.
|
||||
@param context Stream context initialized by #nestegg_init.
|
||||
@retval 0 The media has no cues.
|
||||
@retval 1 The media has cues. */
|
||||
int nestegg_has_cues(nestegg * context);
|
||||
|
||||
/**
|
||||
* Try to determine if the buffer looks like the beginning of a WebM file.
|
||||
*
|
||||
* @param buffer A buffer containing the beginning of a media file.
|
||||
* @param length The size of the buffer.
|
||||
* @retval 0 The file is not a WebM file.
|
||||
* @retval 1 The file is a WebM file. */
|
||||
int nestegg_sniff(unsigned char const * buffer, size_t length);
|
||||
|
||||
/**
|
||||
* Set the underlying allocation function for library allocations.
|
||||
*
|
||||
* @param realloc_func The desired function.
|
||||
*/
|
||||
void nestegg_set_halloc_func(void * (* realloc_func)(void *, size_t));
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue