comparison mpeg.c @ 2718:1bbb4fa1cdcd libavformat

correctly set audio codec when demuxing sofdec files samples: http://samples.mplayerhq.hu/game-formats/sfd/
author aurel
date Wed, 07 Nov 2007 23:56:00 +0000
parents 26a111e617a8
children 5dbc1dfc1300
comparison
equal deleted inserted replaced
2717:4cfddd2c98a5 2718:1bbb4fa1cdcd
105 105
106 106
107 typedef struct MpegDemuxContext { 107 typedef struct MpegDemuxContext {
108 int32_t header_state; 108 int32_t header_state;
109 unsigned char psm_es_type[256]; 109 unsigned char psm_es_type[256];
110 int sofdec;
110 } MpegDemuxContext; 111 } MpegDemuxContext;
111 112
112 static int mpegps_read_header(AVFormatContext *s, 113 static int mpegps_read_header(AVFormatContext *s,
113 AVFormatParameters *ap) 114 AVFormatParameters *ap)
114 { 115 {
115 MpegDemuxContext *m = s->priv_data; 116 MpegDemuxContext *m = s->priv_data;
117 uint8_t buffer[8192];
118 char *p;
119
116 m->header_state = 0xff; 120 m->header_state = 0xff;
117 s->ctx_flags |= AVFMTCTX_NOHEADER; 121 s->ctx_flags |= AVFMTCTX_NOHEADER;
122
123 get_buffer(&s->pb, buffer, sizeof(buffer));
124 if ((p=memchr(buffer, 'S', sizeof(buffer))))
125 if (!memcmp(p, "Sofdec", 6))
126 m->sofdec = 1;
127 url_fseek(&s->pb, -sizeof(buffer), SEEK_CUR);
118 128
119 /* no need to do more */ 129 /* no need to do more */
120 return 0; 130 return 0;
121 } 131 }
122 132
447 else 457 else
448 codec_id = CODEC_ID_MPEG2VIDEO; 458 codec_id = CODEC_ID_MPEG2VIDEO;
449 type = CODEC_TYPE_VIDEO; 459 type = CODEC_TYPE_VIDEO;
450 } else if (startcode >= 0x1c0 && startcode <= 0x1df) { 460 } else if (startcode >= 0x1c0 && startcode <= 0x1df) {
451 type = CODEC_TYPE_AUDIO; 461 type = CODEC_TYPE_AUDIO;
452 codec_id = CODEC_ID_MP2; 462 codec_id = m->sofdec ? CODEC_ID_ADPCM_ADX : CODEC_ID_MP2;
453 } else if (startcode >= 0x80 && startcode <= 0x87) { 463 } else if (startcode >= 0x80 && startcode <= 0x87) {
454 type = CODEC_TYPE_AUDIO; 464 type = CODEC_TYPE_AUDIO;
455 codec_id = CODEC_ID_AC3; 465 codec_id = CODEC_ID_AC3;
456 } else if ((startcode >= 0x88 && startcode <= 0x8f) 466 } else if ((startcode >= 0x88 && startcode <= 0x8f)
457 ||( startcode >= 0x98 && startcode <= 0x9f)) { 467 ||( startcode >= 0x98 && startcode <= 0x9f)) {