comparison libmpdemux/demux_mpg.c @ 16310:fb95057e370e

support MPEG in GXF container with extension-based detection.
author reimar
date Fri, 26 Aug 2005 17:40:02 +0000
parents 6b86089c2edd
children 6720cdd99559
comparison
equal deleted inserted replaced
16309:aa7829aa8428 16310:fb95057e370e
501 static int demux_mpg_es_fill_buffer(demuxer_t *demux, demux_stream_t *ds){ 501 static int demux_mpg_es_fill_buffer(demuxer_t *demux, demux_stream_t *ds){
502 // Elementary video stream 502 // Elementary video stream
503 if(demux->stream->eof) return 0; 503 if(demux->stream->eof) return 0;
504 demux->filepos=stream_tell(demux->stream); 504 demux->filepos=stream_tell(demux->stream);
505 ds_read_packet(demux->video,demux->stream,STREAM_BUFFER_SIZE,0,demux->filepos,0); 505 ds_read_packet(demux->video,demux->stream,STREAM_BUFFER_SIZE,0,demux->filepos,0);
506 return 1;
507 }
508
509 static int demux_mpg_gxf_fill_buffer(demuxer_t *demux, demux_stream_t *ds) {
510 demux_packet_t *pack;
511 uint32_t state = (uint32_t)demux->priv;
512 int pos = 0;
513 int discard = 0;
514 unsigned char *buf;
515 if (demux->stream->eof)
516 return 0;
517 demux->filepos = stream_tell(demux->stream);
518 pack = new_demux_packet(STREAM_BUFFER_SIZE);
519 buf = pack->buffer;
520 while (pos < STREAM_BUFFER_SIZE) {
521 register int c = stream_read_char(demux->stream);
522 if (c < 0) { // EOF
523 resize_demux_packet(pack, pos);
524 break;
525 }
526 state = state << 8 | c;
527 if (state == 0x1bc || state == 0x1bf)
528 discard = 1;
529 else if (state == 0x100)
530 discard = 0;
531 if (!discard)
532 buf[pos++] = c;
533 }
534 ds_add_packet(ds, pack);
535 demux->priv = (void *)state;
506 return 1; 536 return 1;
507 } 537 }
508 538
509 int demux_mpg_fill_buffer(demuxer_t *demux, demux_stream_t *ds){ 539 int demux_mpg_fill_buffer(demuxer_t *demux, demux_stream_t *ds){
510 unsigned int head=0; 540 unsigned int head=0;
787 sh_video=demuxer->video->sh;sh_video->ds=demuxer->video; 817 sh_video=demuxer->video->sh;sh_video->ds=demuxer->video;
788 818
789 return demuxer; 819 return demuxer;
790 } 820 }
791 821
822 static demuxer_t *demux_mpg_gxf_open(demuxer_t *demuxer) {
823 demuxer->audio->sh = NULL;
824 demuxer->video->sh = new_sh_video(demuxer,0);
825 ((sh_video_t *)demuxer->video->sh)->ds = demuxer->video;
826 demuxer->priv = (void *) 0xffffffff;
827 return demuxer;
828 }
792 829
793 static demuxer_t* demux_mpg_ps_open(demuxer_t* demuxer) 830 static demuxer_t* demux_mpg_ps_open(demuxer_t* demuxer)
794 { 831 {
795 sh_audio_t *sh_audio=NULL; 832 sh_audio_t *sh_audio=NULL;
796 sh_video_t *sh_video=NULL; 833 sh_video_t *sh_video=NULL;
842 demux_seek_mpg, 879 demux_seek_mpg,
843 NULL 880 NULL
844 }; 881 };
845 882
846 883
884 demuxer_desc_t demuxer_desc_mpeg_gxf = {
885 "MPEG ES in GXF demuxer",
886 "mpeggxf",
887 "MPEG-ES in GXF",
888 "Reimar Döffinger",
889 "Mpeg",
890 DEMUXER_TYPE_MPEG_GXF,
891 0, // hack autodetection
892 NULL,
893 demux_mpg_gxf_fill_buffer,
894 demux_mpg_gxf_open,
895 NULL,
896 NULL,
897 NULL
898 };
899
847 demuxer_desc_t demuxer_desc_mpeg_es = { 900 demuxer_desc_t demuxer_desc_mpeg_es = {
848 "MPEG ES demuxer", 901 "MPEG ES demuxer",
849 "mpeges", 902 "mpeges",
850 "MPEG-ES", 903 "MPEG-ES",
851 "Arpi?", 904 "Arpi?",