comparison libnut.c @ 1600:72cb68e511e4 libavformat

sync to libnut, nom->num
author ods15
date Sat, 23 Dec 2006 12:33:37 +0000
parents 518d9cecef02
children 2a85c82b8538
comparison
equal deleted inserted replaced
1599:1be19e4024a0 1600:72cb68e511e4
46 46
47 for (i = 0; i < avf->nb_streams; i++) { 47 for (i = 0; i < avf->nb_streams; i++) {
48 AVCodecContext * codec = avf->streams[i]->codec; 48 AVCodecContext * codec = avf->streams[i]->codec;
49 int j; 49 int j;
50 int fourcc = 0; 50 int fourcc = 0;
51 int nom, denom, ssize; 51 int num, denom, ssize;
52 52
53 s[i].type = codec->codec_type == CODEC_TYPE_VIDEO ? NUT_VIDEO_CLASS : NUT_AUDIO_CLASS; 53 s[i].type = codec->codec_type == CODEC_TYPE_VIDEO ? NUT_VIDEO_CLASS : NUT_AUDIO_CLASS;
54 54
55 if (codec->codec_tag) fourcc = codec->codec_tag; 55 if (codec->codec_tag) fourcc = codec->codec_tag;
56 else fourcc = codec_get_tag(nut_tags, codec->codec_id); 56 else fourcc = codec_get_tag(nut_tags, codec->codec_id);
62 62
63 s[i].fourcc_len = 4; 63 s[i].fourcc_len = 4;
64 s[i].fourcc = av_malloc(s[i].fourcc_len); 64 s[i].fourcc = av_malloc(s[i].fourcc_len);
65 for (j = 0; j < s[i].fourcc_len; j++) s[i].fourcc[j] = (fourcc >> (j*8)) & 0xFF; 65 for (j = 0; j < s[i].fourcc_len; j++) s[i].fourcc[j] = (fourcc >> (j*8)) & 0xFF;
66 66
67 ff_parse_specific_params(codec, &nom, &ssize, &denom); 67 ff_parse_specific_params(codec, &num, &ssize, &denom);
68 av_set_pts_info(avf->streams[i], 60, denom, nom); 68 av_set_pts_info(avf->streams[i], 60, denom, num);
69 69
70 s[i].time_base.nom = denom; 70 s[i].time_base.num = denom;
71 s[i].time_base.den = nom; 71 s[i].time_base.den = num;
72 72
73 s[i].fixed_fps = 0; 73 s[i].fixed_fps = 0;
74 s[i].decode_delay = codec->has_b_frames; 74 s[i].decode_delay = codec->has_b_frames;
75 s[i].codec_specific_len = codec->extradata_size; 75 s[i].codec_specific_len = codec->extradata_size;
76 s[i].codec_specific = codec->extradata; 76 s[i].codec_specific = codec->extradata;
80 s[i].height = codec->height; 80 s[i].height = codec->height;
81 s[i].sample_width = 0; 81 s[i].sample_width = 0;
82 s[i].sample_height = 0; 82 s[i].sample_height = 0;
83 s[i].colorspace_type = 0; 83 s[i].colorspace_type = 0;
84 } else { 84 } else {
85 s[i].samplerate_nom = codec->sample_rate; 85 s[i].samplerate_num = codec->sample_rate;
86 s[i].samplerate_denom = 1; 86 s[i].samplerate_denom = 1;
87 s[i].channel_count = codec->channels; 87 s[i].channel_count = codec->channels;
88 } 88 }
89 } 89 }
90 90
197 if (st->codec->extradata_size) { 197 if (st->codec->extradata_size) {
198 st->codec->extradata = av_mallocz(st->codec->extradata_size); 198 st->codec->extradata = av_mallocz(st->codec->extradata_size);
199 memcpy(st->codec->extradata, s[i].codec_specific, st->codec->extradata_size); 199 memcpy(st->codec->extradata, s[i].codec_specific, st->codec->extradata_size);
200 } 200 }
201 201
202 av_set_pts_info(avf->streams[i], 60, s[i].time_base.nom, s[i].time_base.den); 202 av_set_pts_info(avf->streams[i], 60, s[i].time_base.num, s[i].time_base.den);
203 st->start_time = 0; 203 st->start_time = 0;
204 st->duration = s[i].max_pts; 204 st->duration = s[i].max_pts;
205 205
206 st->codec->codec_id = codec_get_id(nut_tags, st->codec->codec_tag); 206 st->codec->codec_id = codec_get_id(nut_tags, st->codec->codec_tag);
207 207
209 case NUT_AUDIO_CLASS: 209 case NUT_AUDIO_CLASS:
210 st->codec->codec_type = CODEC_TYPE_AUDIO; 210 st->codec->codec_type = CODEC_TYPE_AUDIO;
211 if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_wav_id(st->codec->codec_tag); 211 if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_wav_id(st->codec->codec_tag);
212 212
213 st->codec->channels = s[i].channel_count; 213 st->codec->channels = s[i].channel_count;
214 st->codec->sample_rate = s[i].samplerate_nom / s[i].samplerate_denom; 214 st->codec->sample_rate = s[i].samplerate_num / s[i].samplerate_denom;
215 break; 215 break;
216 case NUT_VIDEO_CLASS: 216 case NUT_VIDEO_CLASS:
217 st->codec->codec_type = CODEC_TYPE_VIDEO; 217 st->codec->codec_type = CODEC_TYPE_VIDEO;
218 if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_bmp_id(st->codec->codec_tag); 218 if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_bmp_id(st->codec->codec_tag);
219 219
253 } 253 }
254 254
255 static int nut_read_seek(AVFormatContext * avf, int stream_index, int64_t target_ts, int flags) { 255 static int nut_read_seek(AVFormatContext * avf, int stream_index, int64_t target_ts, int flags) {
256 NUTContext * priv = avf->priv_data; 256 NUTContext * priv = avf->priv_data;
257 int active_streams[] = { stream_index, -1 }; 257 int active_streams[] = { stream_index, -1 };
258 double time_pos = target_ts * priv->s[stream_index].time_base.nom / (double)priv->s[stream_index].time_base.den; 258 double time_pos = target_ts * priv->s[stream_index].time_base.num / (double)priv->s[stream_index].time_base.den;
259 259
260 if (nut_seek(priv->nut, time_pos, 2*!(flags & AVSEEK_FLAG_BACKWARD), active_streams)) return -1; 260 if (nut_seek(priv->nut, time_pos, 2*!(flags & AVSEEK_FLAG_BACKWARD), active_streams)) return -1;
261 261
262 return 0; 262 return 0;
263 } 263 }