Mercurial > libavformat.hg
comparison sierravmd.c @ 820:feca73904e67 libavformat
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
author | michael |
---|---|
date | Sun, 17 Jul 2005 22:24:36 +0000 |
parents | 5f9e330500d9 |
children | 91dcb9da9be6 |
comparison
equal
deleted
inserted
replaced
819:a6c035e7f429 | 820:feca73904e67 |
---|---|
129 st = av_new_stream(s, 0); | 129 st = av_new_stream(s, 0); |
130 if (!st) | 130 if (!st) |
131 return AVERROR_NOMEM; | 131 return AVERROR_NOMEM; |
132 av_set_pts_info(st, 33, 1, 90000); | 132 av_set_pts_info(st, 33, 1, 90000); |
133 vmd->video_stream_index = st->index; | 133 vmd->video_stream_index = st->index; |
134 st->codec.codec_type = CODEC_TYPE_VIDEO; | 134 st->codec->codec_type = CODEC_TYPE_VIDEO; |
135 st->codec.codec_id = CODEC_ID_VMDVIDEO; | 135 st->codec->codec_id = CODEC_ID_VMDVIDEO; |
136 st->codec.codec_tag = 0; /* no fourcc */ | 136 st->codec->codec_tag = 0; /* no fourcc */ |
137 st->codec.width = LE_16(&vmd->vmd_header[12]); | 137 st->codec->width = LE_16(&vmd->vmd_header[12]); |
138 st->codec.height = LE_16(&vmd->vmd_header[14]); | 138 st->codec->height = LE_16(&vmd->vmd_header[14]); |
139 st->codec.extradata_size = VMD_HEADER_SIZE; | 139 st->codec->extradata_size = VMD_HEADER_SIZE; |
140 st->codec.extradata = av_malloc(VMD_HEADER_SIZE); | 140 st->codec->extradata = av_malloc(VMD_HEADER_SIZE); |
141 memcpy(st->codec.extradata, vmd->vmd_header, VMD_HEADER_SIZE); | 141 memcpy(st->codec->extradata, vmd->vmd_header, VMD_HEADER_SIZE); |
142 | 142 |
143 /* if sample rate is 0, assume no audio */ | 143 /* if sample rate is 0, assume no audio */ |
144 vmd->sample_rate = LE_16(&vmd->vmd_header[804]); | 144 vmd->sample_rate = LE_16(&vmd->vmd_header[804]); |
145 if (vmd->sample_rate) { | 145 if (vmd->sample_rate) { |
146 st = av_new_stream(s, 0); | 146 st = av_new_stream(s, 0); |
147 if (!st) | 147 if (!st) |
148 return AVERROR_NOMEM; | 148 return AVERROR_NOMEM; |
149 av_set_pts_info(st, 33, 1, 90000); | 149 av_set_pts_info(st, 33, 1, 90000); |
150 vmd->audio_stream_index = st->index; | 150 vmd->audio_stream_index = st->index; |
151 st->codec.codec_type = CODEC_TYPE_AUDIO; | 151 st->codec->codec_type = CODEC_TYPE_AUDIO; |
152 st->codec.codec_id = CODEC_ID_VMDAUDIO; | 152 st->codec->codec_id = CODEC_ID_VMDAUDIO; |
153 st->codec.codec_tag = 0; /* no codec tag */ | 153 st->codec->codec_tag = 0; /* no codec tag */ |
154 st->codec.channels = (vmd->vmd_header[811] & 0x80) ? 2 : 1; | 154 st->codec->channels = (vmd->vmd_header[811] & 0x80) ? 2 : 1; |
155 st->codec.sample_rate = vmd->sample_rate; | 155 st->codec->sample_rate = vmd->sample_rate; |
156 st->codec.block_align = vmd->audio_block_align = | 156 st->codec->block_align = vmd->audio_block_align = |
157 LE_16(&vmd->vmd_header[806]); | 157 LE_16(&vmd->vmd_header[806]); |
158 if (st->codec.block_align & 0x8000) { | 158 if (st->codec->block_align & 0x8000) { |
159 st->codec.bits_per_sample = 16; | 159 st->codec->bits_per_sample = 16; |
160 st->codec.block_align = -(st->codec.block_align - 0x10000); | 160 st->codec->block_align = -(st->codec->block_align - 0x10000); |
161 } else | 161 } else |
162 st->codec.bits_per_sample = 16; | 162 st->codec->bits_per_sample = 16; |
163 // st->codec.bits_per_sample = 8; | 163 // st->codec->bits_per_sample = 8; |
164 st->codec.bit_rate = st->codec.sample_rate * | 164 st->codec->bit_rate = st->codec->sample_rate * |
165 st->codec.bits_per_sample * st->codec.channels; | 165 st->codec->bits_per_sample * st->codec->channels; |
166 | 166 |
167 /* for calculating pts */ | 167 /* for calculating pts */ |
168 vmd->audio_frame_divisor = st->codec.bits_per_sample / 8 / | 168 vmd->audio_frame_divisor = st->codec->bits_per_sample / 8 / |
169 st->codec.channels; | 169 st->codec->channels; |
170 | 170 |
171 video_pts_inc = 90000; | 171 video_pts_inc = 90000; |
172 video_pts_inc *= st->codec.block_align; | 172 video_pts_inc *= st->codec->block_align; |
173 video_pts_inc /= st->codec.sample_rate; | 173 video_pts_inc /= st->codec->sample_rate; |
174 } else { | 174 } else { |
175 /* if no audio, assume 10 frames/second */ | 175 /* if no audio, assume 10 frames/second */ |
176 video_pts_inc = 90000 / 10; | 176 video_pts_inc = 90000 / 10; |
177 } | 177 } |
178 | 178 |