1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
/*******************************************************************************#
# guvcview http://guvcview.sourceforge.net #
# #
# Paulo Assis <pj.assis@gmail.com> #
# #
# This is a heavily modified version of the matroska interface from x264 #
# Copyright (C) 2005 Mike Matsnev #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
# #
********************************************************************************/
#ifndef AVI_H
#define AVI_H
#include <inttypes.h>
#include <sys/types.h>
#include "stream_io.h"
#include "file_io.h"
#define AVI_MAX_TRACKS 8
#define FRAME_RATE_SCALE 1000 //1000000
typedef struct _video_index_entry_t
{
off_t key;
off_t pos;
off_t len;
} video_index_entry_t;
typedef struct _audio_index_entry_t
{
off_t pos;
off_t len;
off_t tot;
} audio_index_entry_t;
typedef struct avi_I_entry_t
{
unsigned int flags, pos, len;
} avi_I_entry_t;
typedef struct avi_index_t
{
int64_t indx_start;
int entry;
int ents_allocated;
avi_I_entry_t **cluster;
} avi_index_t;
typedef struct _avi_riff_t
{
int64_t riff_start, movi_list;
//int64_t frames_hdr_all;
int64_t time_delay_off;
int id;
struct _avi_riff_t *previous, *next;
} avi_riff_t;
typedef struct avi_RIFF avi_RIFF;
typedef struct avi_context_t
{
io_writer_t *writer;
int flags; /* 0 - AVI is recordind; 1 - AVI is not recording*/
uint32_t avi_flags;
int32_t time_base_num; /* video time base numerator */
int32_t time_base_den; /* video time base denominator */
avi_riff_t *riff_list; // avi_riff list (NULL terminated)
int riff_list_size;
stream_io_t *stream_list;
int stream_list_size;
double fps;
int64_t odml_list; /*,time_delay_off*/ ; //some file offsets
} avi_context_t;
avi_context_t *avi_create_context(const char *filename);
stream_io_t *avi_add_video_stream(
avi_context_t *avi_ctx,
int32_t width,
int32_t height,
int32_t fps,
int32_t fps_num,
int32_t codec_id);
stream_io_t *avi_add_audio_stream(
avi_context_t *avi_ctx,
int32_t channels,
int32_t rate,
int32_t bits,
int32_t mpgrate,
int32_t codec_id,
int32_t format);
int avi_write_packet(
avi_context_t *avi_ctx,
int stream_index,
uint8_t *data,
uint32_t size,
int64_t dts,
int block_align,
int32_t flags);
avi_riff_t *avi_add_new_riff(avi_context_t *avi_ctx);
int avi_close(avi_context_t *avi_ctx);
void avi_destroy_context(avi_context_t *avi_ctx);
#endif
|