Mercurial > mplayer.hg
comparison libmpdemux/demuxer.c @ 27054:eb7dfb6481c1
cosmetics: consistent * placement
author | diego |
---|---|
date | Mon, 16 Jun 2008 12:04:58 +0000 |
parents | 3c993cb3558e |
children | 03e4ae6a3704 |
comparison
equal
deleted
inserted
replaced
27053:3c993cb3558e | 27054:eb7dfb6481c1 |
---|---|
76 | 76 |
77 /* Please do not add any new demuxers here. If you want to implement a new | 77 /* Please do not add any new demuxers here. If you want to implement a new |
78 * demuxer, add it to libavformat, except for wrappers around external | 78 * demuxer, add it to libavformat, except for wrappers around external |
79 * libraries and demuxers requiring binary support. */ | 79 * libraries and demuxers requiring binary support. */ |
80 | 80 |
81 const demuxer_desc_t* const demuxer_list[] = { | 81 const demuxer_desc_t *const demuxer_list[] = { |
82 &demuxer_desc_rawaudio, | 82 &demuxer_desc_rawaudio, |
83 &demuxer_desc_rawvideo, | 83 &demuxer_desc_rawvideo, |
84 #ifdef USE_TV | 84 #ifdef USE_TV |
85 &demuxer_desc_tv, | 85 &demuxer_desc_tv, |
86 #endif | 86 #endif |
157 free(ds); | 157 free(ds); |
158 } | 158 } |
159 | 159 |
160 demux_stream_t *new_demuxer_stream(struct demuxer_st *demuxer, int id) | 160 demux_stream_t *new_demuxer_stream(struct demuxer_st *demuxer, int id) |
161 { | 161 { |
162 demux_stream_t* ds=malloc(sizeof(demux_stream_t)); | 162 demux_stream_t *ds = malloc(sizeof(demux_stream_t)); |
163 ds->buffer_pos=ds->buffer_size=0; | 163 ds->buffer_pos=ds->buffer_size=0; |
164 ds->buffer=NULL; | 164 ds->buffer=NULL; |
165 ds->pts=0; | 165 ds->pts=0; |
166 ds->pts_bytes=0; | 166 ds->pts_bytes=0; |
167 ds->eof=0; | 167 ds->eof=0; |
189 * Get demuxer description structure for a given demuxer type | 189 * Get demuxer description structure for a given demuxer type |
190 * | 190 * |
191 * @param file_format type of the demuxer | 191 * @param file_format type of the demuxer |
192 * @return structure for the demuxer, NULL if not found | 192 * @return structure for the demuxer, NULL if not found |
193 */ | 193 */ |
194 static const demuxer_desc_t* get_demuxer_desc_from_type(int file_format) | 194 static const demuxer_desc_t *get_demuxer_desc_from_type(int file_format) |
195 { | 195 { |
196 int i; | 196 int i; |
197 | 197 |
198 for (i = 0; demuxer_list[i]; i++) | 198 for (i = 0; demuxer_list[i]; i++) |
199 if (file_format == demuxer_list[i]->type) | 199 if (file_format == demuxer_list[i]->type) |
260 #endif | 260 #endif |
261 free(sh->lang); | 261 free(sh->lang); |
262 free(sh); | 262 free(sh); |
263 } | 263 } |
264 | 264 |
265 sh_audio_t* new_sh_audio_aid(demuxer_t *demuxer, int id, int aid) | 265 sh_audio_t *new_sh_audio_aid(demuxer_t *demuxer, int id, int aid) |
266 { | 266 { |
267 if (id > MAX_A_STREAMS-1 || id < 0) { | 267 if (id > MAX_A_STREAMS-1 || id < 0) { |
268 mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested audio stream id overflow (%d > %d)\n", | 268 mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested audio stream id overflow (%d > %d)\n", |
269 id, MAX_A_STREAMS); | 269 id, MAX_A_STREAMS); |
270 return NULL; | 270 return NULL; |
296 free(sh->codecdata); | 296 free(sh->codecdata); |
297 free(sh->lang); | 297 free(sh->lang); |
298 free(sh); | 298 free(sh); |
299 } | 299 } |
300 | 300 |
301 sh_video_t* new_sh_video_vid(demuxer_t *demuxer, int id, int vid) | 301 sh_video_t *new_sh_video_vid(demuxer_t *demuxer, int id, int vid) |
302 { | 302 { |
303 if (id > MAX_V_STREAMS - 1 || id < 0) { | 303 if (id > MAX_V_STREAMS - 1 || id < 0) { |
304 mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested video stream id overflow (%d > %d)\n", | 304 mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested video stream id overflow (%d > %d)\n", |
305 id, MAX_V_STREAMS); | 305 id, MAX_V_STREAMS); |
306 return NULL; | 306 return NULL; |
629 return len; | 629 return len; |
630 } | 630 } |
631 | 631 |
632 double ds_get_next_pts(demux_stream_t *ds) | 632 double ds_get_next_pts(demux_stream_t *ds) |
633 { | 633 { |
634 demuxer_t* demux = ds->demuxer; | 634 demuxer_t *demux = ds->demuxer; |
635 while (!ds->first) { | 635 while (!ds->first) { |
636 if(demux->audio->packs >= MAX_PACKS || demux->audio->bytes >= MAX_PACK_BYTES){ | 636 if(demux->audio->packs >= MAX_PACKS || demux->audio->bytes >= MAX_PACK_BYTES){ |
637 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyAudioInBuffer,demux->audio->packs,demux->audio->bytes); | 637 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyAudioInBuffer,demux->audio->packs,demux->audio->bytes); |
638 mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI); | 638 mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI); |
639 return MP_NOPTS_VALUE; | 639 return MP_NOPTS_VALUE; |
724 Also the stream can override the file_format so a demuxer which rely | 724 Also the stream can override the file_format so a demuxer which rely |
725 on a special stream type can set file_format at the stream level | 725 on a special stream type can set file_format at the stream level |
726 (ex: tv,mf). | 726 (ex: tv,mf). |
727 */ | 727 */ |
728 | 728 |
729 static demuxer_t* demux_open_stream(stream_t *stream, int file_format, | 729 static demuxer_t *demux_open_stream(stream_t *stream, int file_format, |
730 int force, int audio_id, int video_id, | 730 int force, int audio_id, int video_id, |
731 int dvdsub_id, char *filename) | 731 int dvdsub_id, char *filename) |
732 { | 732 { |
733 demuxer_t *demuxer=NULL; | 733 demuxer_t *demuxer=NULL; |
734 | 734 |
877 } | 877 } |
878 #endif | 878 #endif |
879 return demuxer; | 879 return demuxer; |
880 } | 880 } |
881 | 881 |
882 char* audio_stream = NULL; | 882 char *audio_stream = NULL; |
883 char* sub_stream = NULL; | 883 char *sub_stream = NULL; |
884 int audio_stream_cache = 0; | 884 int audio_stream_cache = 0; |
885 | 885 |
886 char *demuxer_name = NULL; // parameter from -demuxer | 886 char *demuxer_name = NULL; // parameter from -demuxer |
887 char *audio_demuxer_name = NULL; // parameter from -audio-demuxer | 887 char *audio_demuxer_name = NULL; // parameter from -audio-demuxer |
888 char *sub_demuxer_name = NULL; // parameter from -sub-demuxer | 888 char *sub_demuxer_name = NULL; // parameter from -sub-demuxer |
1194 else | 1194 else |
1195 demuxer->video->sh = NULL; | 1195 demuxer->video->sh = NULL; |
1196 return index; | 1196 return index; |
1197 } | 1197 } |
1198 | 1198 |
1199 int demuxer_add_attachment(demuxer_t* demuxer, const char* name, | 1199 int demuxer_add_attachment(demuxer_t *demuxer, const char *name, |
1200 const char* type, const void* data, size_t size) | 1200 const char *type, const void *data, size_t size) |
1201 { | 1201 { |
1202 if (!(demuxer->num_attachments & 31)) | 1202 if (!(demuxer->num_attachments & 31)) |
1203 demuxer->attachments = realloc(demuxer->attachments, (demuxer->num_attachments + 32) * sizeof(demux_attachment_t)); | 1203 demuxer->attachments = realloc(demuxer->attachments, (demuxer->num_attachments + 32) * sizeof(demux_attachment_t)); |
1204 | 1204 |
1205 demuxer->attachments[demuxer->num_attachments].name = strdup(name); | 1205 demuxer->attachments[demuxer->num_attachments].name = strdup(name); |
1298 else { //relative seeking | 1298 else { //relative seeking |
1299 uint64_t now; | 1299 uint64_t now; |
1300 now = (sh_video ? sh_video->pts : (sh_audio ? sh_audio->pts : 0.)) * 1000 + .5; | 1300 now = (sh_video ? sh_video->pts : (sh_audio ? sh_audio->pts : 0.)) * 1000 + .5; |
1301 | 1301 |
1302 for (current = total - 1; current >= 0; --current) { | 1302 for (current = total - 1; current >= 0; --current) { |
1303 demux_chapter_t* chapter = demuxer->chapters + current; | 1303 demux_chapter_t *chapter = demuxer->chapters + current; |
1304 if (chapter->start <= now) | 1304 if (chapter->start <= now) |
1305 break; | 1305 break; |
1306 } | 1306 } |
1307 current += chapter; | 1307 current += chapter; |
1308 } | 1308 } |
1448 } | 1448 } |
1449 | 1449 |
1450 return angle; | 1450 return angle; |
1451 } | 1451 } |
1452 | 1452 |
1453 int demuxer_audio_track_by_lang(demuxer_t* d, char* lang) | 1453 int demuxer_audio_track_by_lang(demuxer_t *d, char *lang) |
1454 { | 1454 { |
1455 int i, len; | 1455 int i, len; |
1456 lang += strspn(lang, ","); | 1456 lang += strspn(lang, ","); |
1457 while ((len = strcspn(lang, ",")) > 0) { | 1457 while ((len = strcspn(lang, ",")) > 0) { |
1458 for (i = 0; i < MAX_A_STREAMS; ++i) { | 1458 for (i = 0; i < MAX_A_STREAMS; ++i) { |
1459 sh_audio_t* sh = d->a_streams[i]; | 1459 sh_audio_t *sh = d->a_streams[i]; |
1460 if (sh && sh->lang && strncmp(sh->lang, lang, len) == 0) | 1460 if (sh && sh->lang && strncmp(sh->lang, lang, len) == 0) |
1461 return sh->aid; | 1461 return sh->aid; |
1462 } | 1462 } |
1463 lang += len; | 1463 lang += len; |
1464 lang += strspn(lang, ","); | 1464 lang += strspn(lang, ","); |
1465 } | 1465 } |
1466 return -1; | 1466 return -1; |
1467 } | 1467 } |
1468 | 1468 |
1469 int demuxer_sub_track_by_lang(demuxer_t* d, char* lang) | 1469 int demuxer_sub_track_by_lang(demuxer_t *d, char *lang) |
1470 { | 1470 { |
1471 int i, len; | 1471 int i, len; |
1472 lang += strspn(lang, ","); | 1472 lang += strspn(lang, ","); |
1473 while ((len = strcspn(lang, ",")) > 0) { | 1473 while ((len = strcspn(lang, ",")) > 0) { |
1474 for (i = 0; i < MAX_S_STREAMS; ++i) { | 1474 for (i = 0; i < MAX_S_STREAMS; ++i) { |
1475 sh_sub_t* sh = d->s_streams[i]; | 1475 sh_sub_t *sh = d->s_streams[i]; |
1476 if (sh && sh->lang && strncmp(sh->lang, lang, len) == 0) | 1476 if (sh && sh->lang && strncmp(sh->lang, lang, len) == 0) |
1477 return sh->sid; | 1477 return sh->sid; |
1478 } | 1478 } |
1479 lang += len; | 1479 lang += len; |
1480 lang += strspn(lang, ","); | 1480 lang += strspn(lang, ","); |
1481 } | 1481 } |
1482 return -1; | 1482 return -1; |
1483 } | 1483 } |
1484 | 1484 |
1485 int demuxer_default_audio_track(demuxer_t* d) | 1485 int demuxer_default_audio_track(demuxer_t *d) |
1486 { | 1486 { |
1487 int i; | 1487 int i; |
1488 for (i = 0; i < MAX_A_STREAMS; ++i) { | 1488 for (i = 0; i < MAX_A_STREAMS; ++i) { |
1489 sh_audio_t* sh = d->a_streams[i]; | 1489 sh_audio_t *sh = d->a_streams[i]; |
1490 if (sh && sh->default_track) | 1490 if (sh && sh->default_track) |
1491 return sh->aid; | 1491 return sh->aid; |
1492 } | 1492 } |
1493 for (i = 0; i < MAX_A_STREAMS; ++i) { | 1493 for (i = 0; i < MAX_A_STREAMS; ++i) { |
1494 sh_audio_t* sh = d->a_streams[i]; | 1494 sh_audio_t *sh = d->a_streams[i]; |
1495 if (sh) | 1495 if (sh) |
1496 return sh->aid; | 1496 return sh->aid; |
1497 } | 1497 } |
1498 return -1; | 1498 return -1; |
1499 } | 1499 } |
1500 | 1500 |
1501 int demuxer_default_sub_track(demuxer_t* d) | 1501 int demuxer_default_sub_track(demuxer_t *d) |
1502 { | 1502 { |
1503 int i; | 1503 int i; |
1504 for (i = 0; i < MAX_S_STREAMS; ++i) { | 1504 for (i = 0; i < MAX_S_STREAMS; ++i) { |
1505 sh_sub_t* sh = d->s_streams[i]; | 1505 sh_sub_t *sh = d->s_streams[i]; |
1506 if (sh && sh->default_track) | 1506 if (sh && sh->default_track) |
1507 return sh->sid; | 1507 return sh->sid; |
1508 } | 1508 } |
1509 return -1; | 1509 return -1; |
1510 } | 1510 } |