comparison raw.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 731af78f150d
children 66cc656ea404
comparison
equal deleted inserted replaced
819:a6c035e7f429 820:feca73904e67
48 if (!st) 48 if (!st)
49 return AVERROR_NOMEM; 49 return AVERROR_NOMEM;
50 if (ap) { 50 if (ap) {
51 id = s->iformat->value; 51 id = s->iformat->value;
52 if (id == CODEC_ID_RAWVIDEO) { 52 if (id == CODEC_ID_RAWVIDEO) {
53 st->codec.codec_type = CODEC_TYPE_VIDEO; 53 st->codec->codec_type = CODEC_TYPE_VIDEO;
54 } else { 54 } else {
55 st->codec.codec_type = CODEC_TYPE_AUDIO; 55 st->codec->codec_type = CODEC_TYPE_AUDIO;
56 } 56 }
57 st->codec.codec_id = id; 57 st->codec->codec_id = id;
58 58
59 switch(st->codec.codec_type) { 59 switch(st->codec->codec_type) {
60 case CODEC_TYPE_AUDIO: 60 case CODEC_TYPE_AUDIO:
61 st->codec.sample_rate = ap->sample_rate; 61 st->codec->sample_rate = ap->sample_rate;
62 st->codec.channels = ap->channels; 62 st->codec->channels = ap->channels;
63 av_set_pts_info(st, 64, 1, st->codec.sample_rate); 63 av_set_pts_info(st, 64, 1, st->codec->sample_rate);
64 break; 64 break;
65 case CODEC_TYPE_VIDEO: 65 case CODEC_TYPE_VIDEO:
66 av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); 66 av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
67 st->codec.width = ap->width; 67 st->codec->width = ap->width;
68 st->codec.height = ap->height; 68 st->codec->height = ap->height;
69 st->codec.pix_fmt = ap->pix_fmt; 69 st->codec->pix_fmt = ap->pix_fmt;
70 if(st->codec.pix_fmt == PIX_FMT_NONE) 70 if(st->codec->pix_fmt == PIX_FMT_NONE)
71 st->codec.pix_fmt= PIX_FMT_YUV420P; 71 st->codec->pix_fmt= PIX_FMT_YUV420P;
72 break; 72 break;
73 default: 73 default:
74 return -1; 74 return -1;
75 } 75 }
76 } else { 76 } else {
131 AVStream *st; 131 AVStream *st;
132 int block_align, byte_rate; 132 int block_align, byte_rate;
133 int64_t pos; 133 int64_t pos;
134 134
135 st = s->streams[0]; 135 st = s->streams[0];
136 switch(st->codec.codec_id) { 136 switch(st->codec->codec_id) {
137 case CODEC_ID_PCM_S16LE: 137 case CODEC_ID_PCM_S16LE:
138 case CODEC_ID_PCM_S16BE: 138 case CODEC_ID_PCM_S16BE:
139 case CODEC_ID_PCM_U16LE: 139 case CODEC_ID_PCM_U16LE:
140 case CODEC_ID_PCM_U16BE: 140 case CODEC_ID_PCM_U16BE:
141 block_align = 2 * st->codec.channels; 141 block_align = 2 * st->codec->channels;
142 byte_rate = block_align * st->codec.sample_rate; 142 byte_rate = block_align * st->codec->sample_rate;
143 break; 143 break;
144 case CODEC_ID_PCM_S8: 144 case CODEC_ID_PCM_S8:
145 case CODEC_ID_PCM_U8: 145 case CODEC_ID_PCM_U8:
146 case CODEC_ID_PCM_MULAW: 146 case CODEC_ID_PCM_MULAW:
147 case CODEC_ID_PCM_ALAW: 147 case CODEC_ID_PCM_ALAW:
148 block_align = st->codec.channels; 148 block_align = st->codec->channels;
149 byte_rate = block_align * st->codec.sample_rate; 149 byte_rate = block_align * st->codec->sample_rate;
150 break; 150 break;
151 default: 151 default:
152 block_align = st->codec.block_align; 152 block_align = st->codec->block_align;
153 byte_rate = st->codec.bit_rate / 8; 153 byte_rate = st->codec->bit_rate / 8;
154 break; 154 break;
155 } 155 }
156 156
157 if (block_align <= 0 || byte_rate <= 0) 157 if (block_align <= 0 || byte_rate <= 0)
158 return -1; 158 return -1;
178 178
179 st = av_new_stream(s, 0); 179 st = av_new_stream(s, 0);
180 if (!st) 180 if (!st)
181 return AVERROR_NOMEM; 181 return AVERROR_NOMEM;
182 182
183 st->codec.codec_type = CODEC_TYPE_AUDIO; 183 st->codec->codec_type = CODEC_TYPE_AUDIO;
184 st->codec.codec_id = CODEC_ID_AC3; 184 st->codec->codec_id = CODEC_ID_AC3;
185 st->need_parsing = 1; 185 st->need_parsing = 1;
186 /* the parameters will be extracted from the compressed bitstream */ 186 /* the parameters will be extracted from the compressed bitstream */
187 return 0; 187 return 0;
188 } 188 }
189 189
193 AVStream *st; 193 AVStream *st;
194 194
195 st = av_new_stream(s, 0); 195 st = av_new_stream(s, 0);
196 if (!st) 196 if (!st)
197 return AVERROR_NOMEM; 197 return AVERROR_NOMEM;
198 st->codec.codec_type = CODEC_TYPE_AUDIO; 198 st->codec->codec_type = CODEC_TYPE_AUDIO;
199 st->codec.codec_id = CODEC_ID_SHORTEN; 199 st->codec->codec_id = CODEC_ID_SHORTEN;
200 st->need_parsing = 1; 200 st->need_parsing = 1;
201 /* the parameters will be extracted from the compressed bitstream */ 201 /* the parameters will be extracted from the compressed bitstream */
202 return 0; 202 return 0;
203 } 203 }
204 204
210 210
211 st = av_new_stream(s, 0); 211 st = av_new_stream(s, 0);
212 if (!st) 212 if (!st)
213 return AVERROR_NOMEM; 213 return AVERROR_NOMEM;
214 214
215 st->codec.codec_type = CODEC_TYPE_AUDIO; 215 st->codec->codec_type = CODEC_TYPE_AUDIO;
216 st->codec.codec_id = CODEC_ID_DTS; 216 st->codec->codec_id = CODEC_ID_DTS;
217 st->need_parsing = 1; 217 st->need_parsing = 1;
218 /* the parameters will be extracted from the compressed bitstream */ 218 /* the parameters will be extracted from the compressed bitstream */
219 return 0; 219 return 0;
220 } 220 }
221 221
227 227
228 st = av_new_stream(s, 0); 228 st = av_new_stream(s, 0);
229 if (!st) 229 if (!st)
230 return AVERROR_NOMEM; 230 return AVERROR_NOMEM;
231 231
232 st->codec.codec_type = CODEC_TYPE_VIDEO; 232 st->codec->codec_type = CODEC_TYPE_VIDEO;
233 st->codec.codec_id = s->iformat->value; 233 st->codec->codec_id = s->iformat->value;
234 st->need_parsing = 1; 234 st->need_parsing = 1;
235 235
236 /* for mjpeg, specify frame rate */ 236 /* for mjpeg, specify frame rate */
237 /* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/ 237 /* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/
238 if (ap && ap->time_base.num) { 238 if (ap && ap->time_base.num) {
239 av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); 239 av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
240 } else if ( st->codec.codec_id == CODEC_ID_MJPEG || 240 } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
241 st->codec.codec_id == CODEC_ID_MPEG4 || 241 st->codec->codec_id == CODEC_ID_MPEG4 ||
242 st->codec.codec_id == CODEC_ID_H264) { 242 st->codec->codec_id == CODEC_ID_H264) {
243 av_set_pts_info(st, 64, 1, 25); 243 av_set_pts_info(st, 64, 1, 25);
244 } 244 }
245 245
246 return 0; 246 return 0;
247 } 247 }
607 static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt) 607 static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
608 { 608 {
609 int packet_size, ret, width, height; 609 int packet_size, ret, width, height;
610 AVStream *st = s->streams[0]; 610 AVStream *st = s->streams[0];
611 611
612 width = st->codec.width; 612 width = st->codec->width;
613 height = st->codec.height; 613 height = st->codec->height;
614 614
615 packet_size = avpicture_get_size(st->codec.pix_fmt, width, height); 615 packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
616 if (packet_size < 0) 616 if (packet_size < 0)
617 return -1; 617 return -1;
618 618
619 ret= av_get_packet(&s->pb, pkt, packet_size); 619 ret= av_get_packet(&s->pb, pkt, packet_size);
620 620