/* 連続する空白を読み飛ばす。 */ static int stream_skip(stream_t* buff) { while (buff->tail != buff->head && (buff->buff[buff->tail] == ' ' || buff->buff[buff->tail] == '\t')) { buff->tail += 1; if (buff->tail == BUFF_SIZE) { buff->tail = 0; } } ssize_t update; if (buff->tail == buff->head) { update = stream_update(buff); if (update > 0) { return stream_skip(buff); } else if (update == ERR_FATAL) { return ERR_FATAL; } } // 複数行ヘッダラインに対応 int size; if (buff->tail <= buff->head) size = buff->head - buff->tail; else size = BUFF_SIZE - (buff->tail - buff->head); if(size >= 3 && buff->buff[buff->tail] == '\r' && buff->buff[(buff->tail + 1) % BUFF_SIZE] == '\n' && (buff->buff[(buff->tail + 1) % BUFF_SIZE] == ' ' || buff->buff[(buff->tail + 1) % BUFF_SIZE] == '\t')) { buff->tail = buff->tail + 3; return stream_skip(buff); } return 0; }
/* ヘッダのフィールド名を取得。 */ int stream_take_headname(stream_t* buff, char* dst, int len) { if (stream_skip(buff) == ERR_FATAL || stream_update(buff) == ERR_FATAL) { return ERR_FATAL; } int i; for (i = 0; i < len; i++) { switch (buff->buff[buff->tail]) { case ' ': case '\t': case '\n': case '\r': case ':': dst[i] = '\0'; if (stream_skip(buff) == ERR_FATAL || stream_take(buff, ":", 1) == ERR_FATAL) { return ERR_FATAL; } else { return 1; } default: dst[i] = tolower(buff->buff[buff->tail]); break; } buff->tail += 1; if (buff->tail == BUFF_SIZE) { buff->tail = 0; } } // reset and throw error buff->tail -= i; fprintf(stderr, "stream_take_headname: too large header name.\n"); return 0; }
static int parse_psm(demuxer_t *demux, int len) { unsigned char c, id, type; unsigned int plen, prog_len, es_map_len; mpg_demuxer_t *priv = (mpg_demuxer_t *) demux->priv; mp_dbg(MSGT_DEMUX,MSGL_V, "PARSE_PSM, len=%d\n", len); if(! len || len > 1018) return 0; c = stream_read_char(demux->stream); if(! (c & 0x80)) { stream_skip(demux->stream, len - 1); //not yet valid, discard return 0; } stream_skip(demux->stream, 1); prog_len = stream_read_word(demux->stream); //length of program descriptors stream_skip(demux->stream, prog_len); //.. that we ignore es_map_len = stream_read_word(demux->stream); //length of elementary streams map es_map_len = FFMIN(es_map_len, len - prog_len - 8); //sanity check while(es_map_len > 0) { type = stream_read_char(demux->stream); id = stream_read_char(demux->stream); if(id >= 0xB0 && id <= 0xEF && priv) { int idoffset = id - 0xB0; switch(type) { case 0x1: priv->es_map[idoffset] = VIDEO_MPEG1; break; case 0x2: priv->es_map[idoffset] = VIDEO_MPEG2; break; case 0x3: case 0x4: priv->es_map[idoffset] = AUDIO_MP2; break; case 0x0f: case 0x11: priv->es_map[idoffset] = AUDIO_AAC; break; case 0x10: priv->es_map[idoffset] = VIDEO_MPEG4; break; case 0x1b: priv->es_map[idoffset] = VIDEO_H264; break; case 0x81: priv->es_map[idoffset] = AUDIO_A52; break; } mp_dbg(MSGT_DEMUX,MSGL_V, "PSM ES, id=0x%x, type=%x, stype: %x\n", id, type, priv->es_map[idoffset]); } plen = stream_read_word(demux->stream); //length of elementary stream descriptors plen = FFMIN(plen, es_map_len); //sanity check stream_skip(demux->stream, plen); //skip descriptors for now es_map_len -= 4 + plen; } stream_skip(demux->stream, 4); //skip crc32 return 1; }
// =========================================================================== static int ty_tmf_filetoparts( demuxer_t *demux, TiVoInfo *tivo ) { int parts = 0; stream_seek(demux->stream, 0); mp_msg( MSGT_DEMUX, MSGL_DBG3, "Dumping tar contents\n" ); while (!demux->stream->eof) { char header[ 512 ]; char *name; char *extension; char *sizestr; int size; loff_t skip; if (stream_read(demux->stream, header, 512) < 512) { mp_msg( MSGT_DEMUX, MSGL_DBG3, "Read bad\n" ); break; } name = header; name[99] = 0; sizestr = &header[124]; sizestr[11] = 0; size = strtol(sizestr, NULL, 8); mp_msg( MSGT_DEMUX, MSGL_DBG3, "name %-20.20s size %-12.12s %d\n", name, sizestr, size ); extension = strrchr(name, '.'); if (extension && strcmp(extension, ".ty") == 0) { if ( parts >= MAX_TMF_PARTS ) { mp_msg( MSGT_DEMUX, MSGL_ERR, "ty:tmf too big\n" ); break; } tivo->tmfparts[ parts ].fileSize = size; tivo->tmfparts[ parts ].startOffset = stream_tell(demux->stream); tivo->tmfparts[ parts ].chunks = size / CHUNKSIZE; mp_msg(MSGT_DEMUX, MSGL_DBG3, "tmf_filetoparts(): index %d, chunks %d\n" "tmf_filetoparts(): size %"PRId64"\n" "tmf_filetoparts(): startOffset %"PRId64"\n", parts, tivo->tmfparts[ parts ].chunks, tivo->tmfparts[ parts ].fileSize, tivo->tmfparts[ parts ].startOffset ); parts++; } // size rounded up to blocks skip = (size + 511) & ~511; stream_skip(demux->stream, skip); } stream_reset(demux->stream); tivo->tmf_totalparts = parts; mp_msg( MSGT_DEMUX, MSGL_DBG3, "tmf_filetoparts(): No More Part Files %d\n", parts ); return 1; }
static int getFrame(demuxer_t *demuxer, FrameInfo *frameInfo) { unsigned int packetSize; frameInfo->channelNo = stream_read_word(demuxer->stream); frameInfo->frameType = stream_read_word(demuxer->stream); packetSize=stream_read_dword(demuxer->stream); if(stream_eof(demuxer->stream)) { frameInfo->frameSize = 0; return 0; } frameInfo->frameSize = packetSize - 8; //sizeof(IME6400Header); frameInfo->paddingSize = (packetSize & PACKET_BLOCK_LAST) ? PACKET_BLOCK_SIZE - (packetSize & PACKET_BLOCK_LAST) : 0; mp_msg(MSGT_DEMUX, MSGL_DBG2, "typ: %d chan: %d size: %zu pad: %zu\n", frameInfo->frameType, frameInfo->channelNo, frameInfo->frameSize, frameInfo->paddingSize); if(!imeHeaderValid(frameInfo)) { // skip this packet stream_skip(demuxer->stream,PACKET_BLOCK_SIZE-8); frameInfo->frameSize = 0; return -1; } return 1; }
static int SkipEnd(struct stream *s, const rar_block_t *hdr) { if (!(hdr->flags & RAR_BLOCK_END_HAS_NEXT)) return -1; if (SkipBlock(s, hdr)) return -1; /* Now, we need to look for a marker block, * It seems that there is garbage at EOF */ for (;;) { bstr peek = stream_peek(s, rar_marker_size); if (peek.len < rar_marker_size) return -1; if (!memcmp(peek.start, rar_marker, rar_marker_size)) break; if (!stream_skip(s, 1)) return -1; } /* Skip marker and archive blocks */ if (IgnoreBlock(s, RAR_BLOCK_MARKER)) return -1; if (IgnoreBlock(s, RAR_BLOCK_ARCHIVE)) return -1; return 0; }
/* ストリームの先頭の(現在の行内の)トークンを取得 */ int stream_take_token(stream_t* buff, char* dst, int len) { if (stream_skip(buff) == ERR_FATAL || stream_update(buff) == ERR_FATAL) { return ERR_FATAL; } int i; for (i = 0; i < len; i++) { switch (buff->buff[buff->tail]) { case ' ': case '\t': case '\n': case '\r': dst[i] = '\0'; return 1; default: dst[i] = buff->buff[buff->tail]; break; } buff->tail += 1; if (buff->tail == BUFF_SIZE) { buff->tail = 0; } } // reset buff->tail -= i; fprintf(stderr, "stream_take_token: Token too long.\n"); return 0; }
/* * Skip the current element, or on error, call ebml_resync_cluster(). */ int ebml_read_skip_or_resync_cluster(stream_t *s, uint64_t *length) { uint64_t len; int l; len = ebml_read_length(s, &l); if (len == EBML_UINT_INVALID) goto resync; if (length) *length = len + l; int64_t pos = stream_tell(s); // When reading corrupted elements, len will often be a random high number, // and stream_skip() will fail when skipping past EOF. if (!stream_skip(s, len)) { stream_seek(s, pos); goto resync; } return 0; resync: return ebml_resync_cluster(s) < 0 ? -1 : 1; }
static int64_t skip_cb(struct archive *arch, void *priv, int64_t request) { struct mp_archive_volume *vol = priv; if (!volume_seek(vol)) return -1; int64_t old = stream_tell(vol->src); stream_skip(vol->src, request); return stream_tell(vol->src) - old; }
// return value: // 0 = EOF or no stream found // 1 = successfully read a packet static int demux_y4m_fill_buffer(demuxer_t *demux, demux_stream_t *dsds) { demux_stream_t *ds=demux->video; demux_packet_t *dp; y4m_priv_t *priv=demux->priv; y4m_frame_info_t fi; unsigned char *buf[3]; int err, size; y4m_init_frame_info(&fi); demux->filepos=stream_tell(demux->stream); size = ((sh_video_t*)ds->sh)->disp_w*((sh_video_t*)ds->sh)->disp_h; dp = new_demux_packet(3*size/2); /* swap U and V components */ buf[0] = dp->buffer; buf[1] = dp->buffer + 5*size/4; buf[2] = dp->buffer + size; if (priv->is_older) { int c; c = stream_read_char(demux->stream); /* F */ if (c == -256) return 0; /* EOF */ if (c != 'F') { mp_msg(MSGT_DEMUX, MSGL_V, "Bad frame at %d\n", (int)stream_tell(demux->stream)-1); return 0; } stream_skip(demux->stream, 5); /* RAME\n */ stream_read(demux->stream, buf[0], size); stream_read(demux->stream, buf[1], size/4); stream_read(demux->stream, buf[2], size/4); } else { if ((err=y4m_read_frame(demux->stream, priv->si, &fi, buf)) != Y4M_OK) { mp_msg(MSGT_DEMUX, MSGL_V, "error reading frame %s\n", y4m_strerr(err)); return 0; } } /* This seems to be the right way to calculate the presentation time stamp */ dp->pts=(float)priv->framenum/((sh_video_t*)ds->sh)->fps; priv->framenum++; dp->pos=demux->filepos; dp->flags=0; ds_add_packet(ds, dp); return 1; }
static int lmlm4_check_file(demuxer_t* demuxer) { FrameInfo frameInfo; unsigned int first; mp_msg(MSGT_DEMUX, MSGL_V, "Checking for LMLM4 Stream Format\n"); if(getFrame(demuxer, &frameInfo)!=1){ stream_skip(demuxer->stream,-8); mp_msg(MSGT_DEMUX, MSGL_V, "LMLM4 Stream Format not found\n"); return 0; } first=stream_read_dword(demuxer->stream); stream_skip(demuxer->stream,-12); mp_msg(MSGT_DEMUXER,MSGL_V,"LMLM4: first=0x%08X\n",first); switch(frameInfo.frameType){ case FRAMETYPE_AUDIO_MPEG1L2: if( (first & 0xffe00000) != 0xffe00000 ){ mp_msg(MSGT_DEMUXER,MSGL_V,"LMLM4: not mpeg audio\n"); return 0; } if((4-((first>>17)&3))!=2){ mp_msg(MSGT_DEMUXER,MSGL_V,"LMLM4: not layer-2\n"); return 0; } if(((first>>10)&0x3)==3){ mp_msg(MSGT_DEMUXER,MSGL_V,"LMLM4: invalid audio sampelrate\n"); return 0; } mp_msg(MSGT_DEMUXER,MSGL_V,"LMLM4: first packet is audio, header checks OK!\n"); break; // TODO: add checks for video header too, for case of disabled audio } // stream_reset(demuxer->stream); mp_msg(MSGT_DEMUX, MSGL_V, "LMLM4 Stream Format found\n"); return DEMUXER_TYPE_LMLM4; }
void get_aac_duration(demuxer_t *demuxer, AVFormatContext *avfc){ uint8_t hdr[8]; int len,nf=0,srate,num,c,framesize,i; loff_t init = stream_tell(demuxer->stream); lavf_priv_t *priv= demuxer->priv; AVCodecContext *codec; stream_seek(demuxer->stream, demuxer->movi_start); while(1){ c = 0; while(c != 0xFF){ c = stream_read_char(demuxer->stream); if(c < 0) break; } hdr[0] = 0xFF; if(stream_read(demuxer->stream, &(hdr[1]), 7) != 7) break; len = aac_parse_frame(hdr, &srate, &num); if(len > 0){ nf++; stream_skip(demuxer->stream, len - 8); }else{ stream_skip(demuxer->stream, -6); } } stream_seek(demuxer->stream, init); for(i=0; i<avfc->nb_streams; i++){ codec= ((AVStream *)avfc->streams[i])->codec; if((framesize = codec->frame_size)>0) break; } //framesize = framesize>0?framesize:1024; framesize = 1024; if(nf && srate){ priv->avfc->duration = (double)((nf*framesize/srate)*AV_TIME_BASE); } }
//This is an almost verbatim copy of high_res_mp3_seek(), from demux_audio.c static void demux_aac_seek(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags) { aac_priv_t *priv = (aac_priv_t *) demuxer->priv; demux_stream_t *d_audio=demuxer->audio; sh_audio_t *sh_audio=d_audio->sh; float time; ds_free_packs(d_audio); time = (flags & SEEK_ABSOLUTE) ? rel_seek_secs - priv->last_pts : rel_seek_secs; if(time < 0) { stream_seek(demuxer->stream, demuxer->movi_start); time = priv->last_pts + time; priv->last_pts = 0; } if(time > 0) { int len, nf, srate, num; nf = time * sh_audio->samplerate/1024; while(nf > 0) { if(stream_read(demuxer->stream,priv->buf, 8) < 8) break; len = aac_parse_frame(priv->buf, &srate, &num); if(len <= 0) { stream_skip(demuxer->stream, -7); continue; } stream_skip(demuxer->stream, len - 8); priv->last_pts += (float) (num*1024.0/srate); nf -= num; } } }
static int SkipBlock(struct stream *s, const rar_block_t *hdr) { uint64_t size = (uint64_t)hdr->size + hdr->add_size; while (size > 0) { int skip = MPMIN(size, INT_MAX); if (!stream_skip(s, skip)) return -1; size -= skip; } return 0; }
// return value: // 0 = EOF or no stream found // 1 = successfully read a packet static int demux_avi_fill_buffer_nini(demuxer_t *demux, demux_stream_t *ds) { avi_priv_t *priv=demux->priv; unsigned int id=0; unsigned int len; int ret=0; off_t *fpos=NULL; if(ds==demux->video) fpos=&priv->idx_pos_v; else if(ds==demux->audio) fpos=&priv->idx_pos_a; else return 0; stream_seek(demux->stream,fpos[0]); do{ demux->filepos=stream_tell(demux->stream); if(demux->filepos>=demux->movi_end && (demux->movi_end>demux->movi_start)){ ds->eof=1; return 0; } id=avi_find_id(demux->stream); len=stream_read_dword_le(demux->stream); if(stream_eof(demux->stream)) return 0; if(id==mmioFOURCC('L','I','S','T')){ id=stream_read_dword_le(demux->stream); // list type continue; } if(id==mmioFOURCC('R','I','F','F')){ mp_msg(MSGT_DEMUX,MSGL_V,"additional RIFF header...\n"); id=stream_read_dword_le(demux->stream); // "AVIX" continue; } if(ds==demux_avi_select_stream(demux,id)){ // read it! ret=demux_avi_read_packet(demux,ds,id,len,priv->idx_pos-1,0); } else { // skip it! int skip=(len+1)&(~1); // total bytes in this chunk stream_skip(demux->stream,skip); } } while(ret!=1); fpos[0]=stream_tell(demux->stream); return 1; }
/* * Skip the next element. */ int ebml_read_skip(stream_t *s, uint64_t *length) { uint64_t len; int l; len = ebml_read_length(s, &l); if (len == EBML_UINT_INVALID) return 1; if (length) *length = len + l; stream_skip(s, len); return 0; }
/// returns DEMUXER_TYPE_AAC if it finds 8 ADTS frames in 32768 bytes, 0 otherwise static int demux_aac_probe(demuxer_t *demuxer) { int cnt = 0, c, len, srate, num; loff_t init, probed; aac_priv_t *priv; if(! demux_aac_init(demuxer)) { mp_msg(MSGT_DEMUX, MSGL_ERR, "COULDN'T INIT aac_demux, exit\n"); return 0; } priv = (aac_priv_t *) demuxer->priv; init = probed = stream_tell(demuxer->stream); while(probed-init <= 32768 && cnt < 8) { c = 0; while(c != 0xFF) { c = stream_read_char(demuxer->stream); if(c < 0) goto fail; } priv->buf[0] = 0xFF; if(stream_read(demuxer->stream, &(priv->buf[1]), 7) < 7) goto fail; len = aac_parse_frame(priv->buf, &srate, &num); if(len > 0) { cnt++; stream_skip(demuxer->stream, len - 8); } probed = stream_tell(demuxer->stream); } stream_seek(demuxer->stream, init); if(cnt < 8) goto fail; mp_msg(MSGT_DEMUX, MSGL_V, "demux_aac_probe, INIT: %"PRIu64", PROBED: %"PRIu64", cnt: %d\n", init, probed, cnt); return DEMUXER_TYPE_AAC; fail: mp_msg(MSGT_DEMUX, MSGL_V, "demux_aac_probe, failed to detect an AAC stream\n"); return 0; }
BOOL ber_read_integer(wStream* s, UINT32* value) { int length; if (!ber_read_universal_tag(s, BER_TAG_INTEGER, FALSE) || !ber_read_length(s, &length) || stream_get_left(s) < length) return FALSE; if (value == NULL) { // even if we don't care the integer value, check the announced size return stream_skip(s, length); } if (length == 1) { stream_read_BYTE(s, *value); } else if (length == 2) { stream_read_UINT16_be(s, *value); } else if (length == 3) { BYTE byte; stream_read_BYTE(s, byte); stream_read_UINT16_be(s, *value); *value += (byte << 16); } else if (length == 4) { stream_read_UINT32_be(s, *value); } else if (length == 8) { printf("%s: should implement reading an 8 bytes integer\n", __FUNCTION__); return FALSE; } else { printf("%s: should implement reading an integer with length=%d\n", __FUNCTION__, length); return FALSE; } return TRUE; }
BOOL license_read_platform_challenge_packet(rdpLicense* license, STREAM* s) { DEBUG_LICENSE("Receiving Platform Challenge Packet"); if(stream_get_left(s) < 4) return FALSE; stream_seek(s, 4); /* ConnectFlags, Reserved (4 bytes) */ /* EncryptedPlatformChallenge */ license->encrypted_platform_challenge->type = BB_ANY_BLOB; license_read_binary_blob(s, license->encrypted_platform_challenge); license->encrypted_platform_challenge->type = BB_ENCRYPTED_DATA_BLOB; /* MACData (16 bytes) */ if(!stream_skip(s, 16)) return FALSE; license_decrypt_platform_challenge(license); return TRUE; }
/* ストリームの先頭がmatchだったら読み飛ばす */ int stream_take(stream_t* buff, const char* match, int sensitive) { if (stream_skip(buff) == ERR_FATAL || stream_update(buff) == ERR_FATAL) { return ERR_FATAL; } int tail = buff->tail; while (buff->tail != buff->head && sensitive_eq(buff->buff[buff->tail], *match, sensitive) && *match != '\0') { buff->tail += 1; match += 1; if (buff->tail == BUFF_SIZE) { buff->tail = 0; } } if (*match == '\0') { return 1; } else { buff->tail = tail; return 0; } }
/* * Skip the current element. * end: the end of the parent element or -1 (for robust error handling) */ int ebml_read_skip(struct mp_log *log, int64_t end, stream_t *s) { uint64_t len; int64_t pos = stream_tell(s); len = ebml_read_length(s); if (len == EBML_UINT_INVALID) goto invalid; int64_t pos2 = stream_tell(s); if (len >= INT64_MAX - pos2 || (end > 0 && pos2 + len > end)) goto invalid; if (!stream_skip(s, len)) goto invalid; return 0; invalid: mp_err(log, "Invalid EBML length at position %"PRId64"\n", pos); stream_seek(s, pos); return 1; }
static int vivo_check_file(demuxer_t* demuxer){ int i=0; int len; int c; unsigned char buf[2048+256]; vivo_priv_t* priv; int orig_pos = stream_tell(demuxer->stream); mp_msg(MSGT_DEMUX,MSGL_V,"Checking for VIVO\n"); c=stream_read_char(demuxer->stream); if(c==-256) return 0; len=0; while((c=stream_read_char(demuxer->stream))>=0x80){ len+=0x80*(c-0x80); if(len>1024) return 0; } len+=c; mp_msg(MSGT_DEMUX,MSGL_V,"header block 1 size: %d\n",len); //stream_skip(demuxer->stream,len); priv=malloc(sizeof(vivo_priv_t)); memset(priv,0,sizeof(vivo_priv_t)); demuxer->priv=priv; #if 0 vivo_parse_text_header(demuxer, len); if (priv->supported == 0) return 0; #else /* this is enought for check (for now) */ stream_read(demuxer->stream,buf,len); buf[len]=0; // printf("VIVO header: '%s'\n",buf); // parse header: i=0; while(i<len && buf[i]==0x0D && buf[i+1]==0x0A) i+=2; // skip empty lines if(strncmp(buf+i,"Version:Vivo/",13)) return 0; // bad version/type! #endif #if 0 c=stream_read_char(demuxer->stream); if(c) return 0; len2=0; while((c=stream_read_char(demuxer->stream))>=0x80){ len2+=0x80*(c-0x80); if(len+len2>2048) return 0; } len2+=c; mp_msg(MSGT_DEMUX,MSGL_V,"header block 2 size: %d\n",len2); stream_skip(demuxer->stream,len2); // stream_read(demuxer->stream,buf+len,len2); #endif // c=stream_read_char(demuxer->stream); // printf("first packet: %02X\n",c); stream_seek(demuxer->stream, orig_pos); return DEMUXER_TYPE_VIVO; }
// return value: // 0 = EOF or no stream found // 1 = successfully read a packet static int demux_vivo_fill_buffer(demuxer_t *demux, demux_stream_t *dsds){ demux_stream_t *ds=NULL; int c; int len=0; int seq; int prefix=0; demux->filepos=stream_tell(demux->stream); c=stream_read_char(demux->stream); if (c == -256) /* EOF */ return 0; // printf("c=%x,%02X\n",c,c&0xf0); if (c == 0x82) { /* ok, this works, but pts calculating from header is required! */ #warning "Calculate PTS from picture header!" prefix = 1; c = stream_read_char(demux->stream); mp_msg(MSGT_DEMUX, MSGL_V, "packet 0x82(pos=%u) chunk=%x\n", (int)stream_tell(demux->stream), c); } switch(c&0xF0){ case 0x00: // header - skip it! { len=stream_read_char(demux->stream); if(len>=0x80) len=0x80*(len-0x80)+stream_read_char(demux->stream); mp_msg(MSGT_DEMUX, MSGL_V, "vivo extra header: %d bytes\n",len); #ifdef TEXTPARSE_ALL { int pos; /* also try to parse all headers */ pos = stream_tell(demux->stream); vivo_parse_text_header(demux, len); stream_seek(demux->stream, pos); } #endif break; } case 0x10: // video packet if (prefix == 1) len = stream_read_char(demux->stream); else len=128; ds=demux->video; break; case 0x20: // video packet len=stream_read_char(demux->stream); ds=demux->video; break; case 0x30: // audio packet if (prefix == 1) len = stream_read_char(demux->stream); else len=40; /* 40kbps */ ds=demux->audio; audio_pos+=len; break; case 0x40: // audio packet if (prefix == 1) len = stream_read_char(demux->stream); else len=24; /* 24kbps */ ds=demux->audio; audio_pos+=len; break; default: mp_msg(MSGT_DEMUX,MSGL_WARN,"VIVO - unknown ID found: %02X at pos %"PRIu64" contact author!\n", c, (int64_t)stream_tell(demux->stream)); return 0; } // printf("chunk=%x, len=%d\n", c, len); if(!ds || ds->id<-1){ if(len) stream_skip(demux->stream,len); return 1; } seq=c&0x0F; if(ds->asf_packet){ if(ds->asf_seq!=seq){ // closed segment, finalize packet: ds_add_packet(ds,ds->asf_packet); ds->asf_packet=NULL; // printf("packet!\n"); } else { // append data to it! demux_packet_t* dp=ds->asf_packet; if(dp->len + len + FF_INPUT_BUFFER_PADDING_SIZE < 0) return 0; dp->buffer=realloc(dp->buffer,dp->len+len+FF_INPUT_BUFFER_PADDING_SIZE); memset(dp->buffer+dp->len+len, 0, FF_INPUT_BUFFER_PADDING_SIZE); //memcpy(dp->buffer+dp->len,data,len); stream_read(demux->stream,dp->buffer+dp->len,len); mp_dbg(MSGT_DEMUX,MSGL_DBG4,"data appended! %d+%d\n",dp->len,len); dp->len+=len; // we are ready now. if((c&0xF0)==0x20) --ds->asf_seq; // hack! return 1; } } // create new packet: { demux_packet_t* dp; dp=new_demux_packet(len); //memcpy(dp->buffer,data,len); stream_read(demux->stream,dp->buffer,len); dp->pts=audio_rate?((float)audio_pos/(float)audio_rate):0; // dp->flags=keyframe; // if(ds==demux->video) printf("ASF time: %8d dur: %5d \n",time,dur); dp->pos=demux->filepos; ds->asf_packet=dp; ds->asf_seq=seq; // we are ready now. return 1; } }
Sound* load_WAV(char *source, char (*get_byte)(char *source)) { Sound *sound=new(Sound); unsigned int source_size; unsigned int source_subchunk_size; unsigned short source_format; unsigned short source_num_channels; unsigned int source_byte_rate; unsigned short source_block_align; unsigned short source_bits_per_sample; if(!stream_next("RIFF", source, get_byte)) { printf("\nERROR file is not WAVE"); return 0; } source_size=stream_get_uint(source, get_byte); if(!stream_next("WAVEfmt ", source, get_byte)) { printf("\nERROR file is not WAVE"); return 0; } source_subchunk_size = stream_get_uint(source, get_byte); source_format = stream_get_ushort(source, get_byte); source_num_channels = stream_get_ushort(source, get_byte); sound->frequency = stream_get_uint(source, get_byte); source_byte_rate = stream_get_uint(source, get_byte); source_block_align = stream_get_ushort(source, get_byte); source_bits_per_sample = stream_get_ushort(source, get_byte); while(!stream_next("data", source, get_byte)) { source_subchunk_size=stream_get_uint(source, get_byte); stream_skip(source_subchunk_size, source, get_byte); } sound->data_size = stream_get_uint(source, get_byte); sound->get_byte = get_byte; sound->source = source; sound->format = AL_FORMAT_STEREO16; sound->load_buffer = load_wav_buffer; ALuint buffers[NUM_BUFFERS]; alGenBuffers(NUM_BUFFERS, buffers); alGenSources(1, &sound->sound_source); load_wav_buffer(sound); alBufferData(buffers[0], sound->format, sound->buffer, sound->buffer_size, sound->frequency); load_wav_buffer(sound); alBufferData(buffers[1], sound->format, sound->buffer, sound->buffer_size, sound->frequency); alSourceQueueBuffers(sound->sound_source, NUM_BUFFERS, buffers); return sound; }
RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, BYTE* data, UINT32 length) { int pos; STREAM* s; UINT32 blockLen; UINT32 blockType; RFX_MESSAGE* message; message = (RFX_MESSAGE*) malloc(sizeof(RFX_MESSAGE)); ZeroMemory(message, sizeof(RFX_MESSAGE)); s = stream_new(0); stream_attach(s, data, length); while (stream_get_left(s) > 6) { /* RFX_BLOCKT */ stream_read_UINT16(s, blockType); /* blockType (2 bytes) */ stream_read_UINT32(s, blockLen); /* blockLen (4 bytes) */ DEBUG_RFX("blockType 0x%X blockLen %d", blockType, blockLen); if (blockLen == 0) { DEBUG_WARN("zero blockLen"); break; } if (stream_get_left(s) < blockLen - 6) { DEBUG_WARN("rfx_process_message: packet too small for blocklen=%d", blockLen); break; } pos = stream_get_pos(s) - 6 + blockLen; if (blockType >= WBT_CONTEXT && blockType <= WBT_EXTENSION) { /* RFX_CODEC_CHANNELT */ /* codecId (1 byte) must be set to 0x01 */ /* channelId (1 byte) must be set to 0x00 */ if (!stream_skip(s, 2)) { DEBUG_WARN("rfx_process_message: unable to skip RFX_CODEC_CHANNELT"); break; } } switch (blockType) { case WBT_SYNC: rfx_process_message_sync(context, s); break; case WBT_CODEC_VERSIONS: rfx_process_message_codec_versions(context, s); break; case WBT_CHANNELS: rfx_process_message_channels(context, s); break; case WBT_CONTEXT: rfx_process_message_context(context, s); break; case WBT_FRAME_BEGIN: rfx_process_message_frame_begin(context, message, s); break; case WBT_FRAME_END: rfx_process_message_frame_end(context, message, s); break; case WBT_REGION: rfx_process_message_region(context, message, s); break; case WBT_EXTENSION: rfx_process_message_tileset(context, message, s); break; default: DEBUG_WARN("unknown blockType 0x%X", blockType); break; } stream_set_pos(s, pos); } stream_detach(s); stream_free(s); return message; }
static demuxer_t* demux_open_smjpeg(demuxer_t* demuxer){ sh_video_t* sh_video; sh_audio_t* sh_audio; unsigned int htype = 0, hleng; int i = 0; /* file header */ stream_skip(demuxer->stream, 8); /* \x00\x0aSMJPEG */ stream_skip(demuxer->stream, 4); mp_msg(MSGT_DEMUX, MSGL_INFO, "This clip is %d seconds\n", stream_read_dword(demuxer->stream)); /* stream header */ while (i < 3) { i++; htype = stream_read_dword_le(demuxer->stream); if (htype == mmioFOURCC('H','E','N','D')) break; hleng = (stream_read_word(demuxer->stream)<<16)|stream_read_word(demuxer->stream); switch(htype) { case mmioFOURCC('_','V','I','D'): sh_video = new_sh_video(demuxer, 0); demuxer->video->sh = sh_video; sh_video->ds = demuxer->video; sh_video->bih = malloc(sizeof(BITMAPINFOHEADER)); memset(sh_video->bih, 0, sizeof(BITMAPINFOHEADER)); stream_skip(demuxer->stream, 4); /* number of frames */ // sh_video->fps = 24; // sh_video->frametime = 1.0f/sh_video->fps; sh_video->disp_w = stream_read_word(demuxer->stream); sh_video->disp_h = stream_read_word(demuxer->stream); sh_video->format = stream_read_dword_le(demuxer->stream); /* these are false values */ sh_video->bih->biSize = 40; sh_video->bih->biWidth = sh_video->disp_w; sh_video->bih->biHeight = sh_video->disp_h; sh_video->bih->biPlanes = 3; sh_video->bih->biBitCount = 12; sh_video->bih->biCompression = sh_video->format; sh_video->bih->biSizeImage = sh_video->disp_w*sh_video->disp_h; break; case mmioFOURCC('_','S','N','D'): sh_audio = new_sh_audio(demuxer, 0); demuxer->audio->sh = sh_audio; sh_audio->ds = demuxer->audio; sh_audio->wf = malloc(sizeof(WAVEFORMATEX)); memset(sh_audio->wf, 0, sizeof(WAVEFORMATEX)); sh_audio->samplerate = stream_read_word(demuxer->stream); sh_audio->wf->wBitsPerSample = stream_read_char(demuxer->stream); sh_audio->channels = stream_read_char(demuxer->stream); sh_audio->format = stream_read_dword_le(demuxer->stream); sh_audio->wf->wFormatTag = sh_audio->format; sh_audio->wf->nChannels = sh_audio->channels; sh_audio->wf->nSamplesPerSec = sh_audio->samplerate; sh_audio->wf->nAvgBytesPerSec = sh_audio->wf->nChannels* sh_audio->wf->wBitsPerSample*sh_audio->wf->nSamplesPerSec/8; sh_audio->wf->nBlockAlign = sh_audio->channels *2; sh_audio->wf->cbSize = 0; break; case mmioFOURCC('_','T','X','T'): stream_skip(demuxer->stream, stream_read_dword(demuxer->stream)); break; } } demuxer->seekable = 0; return demuxer; }
static demuxer_t* demux_open_roq(demuxer_t* demuxer) { sh_video_t *sh_video = NULL; sh_audio_t *sh_audio = NULL; roq_data_t *roq_data = malloc(sizeof(roq_data_t)); int chunk_id; int chunk_size; int chunk_arg; int last_chunk_id = 0; int largest_audio_chunk = 0; int fps; roq_data->total_chunks = 0; roq_data->current_chunk = 0; roq_data->total_video_chunks = 0; roq_data->chunks = NULL; // position the stream and start traversing stream_seek(demuxer->stream, 6); fps = stream_read_word_le(demuxer->stream); while (!stream_eof(demuxer->stream)) { chunk_id = stream_read_word_le(demuxer->stream); chunk_size = stream_read_dword_le(demuxer->stream); chunk_arg = stream_read_word_le(demuxer->stream); // this is the only useful header info in the file if (chunk_id == RoQ_INFO) { // there should only be one RoQ_INFO chunk per file if (sh_video) { mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Found more than one RoQ_INFO chunk\n"); stream_skip(demuxer->stream, 8); } else { // this is a good opportunity to create a video stream header sh_video = new_sh_video(demuxer, 0); // make sure the demuxer knows about the new stream header demuxer->video->sh = sh_video; // make sure that the video demuxer stream header knows about its // parent video demuxer stream sh_video->ds = demuxer->video; sh_video->disp_w = stream_read_word_le(demuxer->stream); sh_video->disp_h = stream_read_word_le(demuxer->stream); stream_skip(demuxer->stream, 4); // custom fourcc for internal MPlayer use sh_video->format = mmioFOURCC('R', 'o', 'Q', 'V'); // constant frame rate sh_video->fps = fps; sh_video->frametime = 1 / sh_video->fps; } } else if ((chunk_id == RoQ_SOUND_MONO) || (chunk_id == RoQ_SOUND_STEREO)) { // create the audio stream header if it hasn't been created it if (sh_audio == NULL) { // make the header first sh_audio = new_sh_audio(demuxer, 0); // make sure the demuxer knows about the new stream header demuxer->audio->id = 0; demuxer->audio->sh = sh_audio; // make sure that the audio demuxer stream header knows about its // parent audio demuxer stream sh_audio->ds = demuxer->audio; // go through the bother of making a WAVEFORMATEX structure sh_audio->wf = malloc(sizeof(*sh_audio->wf)); // custom fourcc for internal MPlayer use sh_audio->format = mmioFOURCC('R', 'o', 'Q', 'A'); if (chunk_id == RoQ_SOUND_STEREO) sh_audio->wf->nChannels = 2; else sh_audio->wf->nChannels = 1; // always 22KHz, 16-bit sh_audio->wf->nSamplesPerSec = 22050; sh_audio->wf->wBitsPerSample = 16; } // index the chunk roq_data->chunks = realloc(roq_data->chunks, (roq_data->total_chunks + 1) * sizeof (roq_chunk_t)); roq_data->chunks[roq_data->total_chunks].chunk_type = CHUNK_TYPE_AUDIO; roq_data->chunks[roq_data->total_chunks].chunk_offset = stream_tell(demuxer->stream) - 8; roq_data->chunks[roq_data->total_chunks].chunk_size = chunk_size + 8; roq_data->chunks[roq_data->total_chunks].running_audio_sample_count = roq_data->total_audio_sample_count; // audio housekeeping if (chunk_size > largest_audio_chunk) largest_audio_chunk = chunk_size; roq_data->total_audio_sample_count += (chunk_size / sh_audio->wf->nChannels); stream_skip(demuxer->stream, chunk_size); roq_data->total_chunks++; } else if ((chunk_id == RoQ_QUAD_CODEBOOK) || ((chunk_id == RoQ_QUAD_VQ) && (last_chunk_id != RoQ_QUAD_CODEBOOK))) { // index a new chunk if it's a codebook or quad VQ not following a // codebook roq_data->chunks = realloc(roq_data->chunks, (roq_data->total_chunks + 1) * sizeof (roq_chunk_t)); roq_data->chunks[roq_data->total_chunks].chunk_type = CHUNK_TYPE_VIDEO; roq_data->chunks[roq_data->total_chunks].chunk_offset = stream_tell(demuxer->stream) - 8; roq_data->chunks[roq_data->total_chunks].chunk_size = chunk_size + 8; roq_data->chunks[roq_data->total_chunks].video_chunk_number = roq_data->total_video_chunks++; stream_skip(demuxer->stream, chunk_size); roq_data->total_chunks++; } else if ((chunk_id == RoQ_QUAD_VQ) && (last_chunk_id == RoQ_QUAD_CODEBOOK)) { // if it's a quad VQ chunk following a codebook chunk, extend the last // chunk roq_data->chunks[roq_data->total_chunks - 1].chunk_size += (chunk_size + 8); stream_skip(demuxer->stream, chunk_size); } else if (!stream_eof(demuxer->stream)) { mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Unknown RoQ chunk ID: %04X\n", chunk_id); } last_chunk_id = chunk_id; } // minimum output buffer size = largest audio chunk * 2, since each byte // in the DPCM encoding effectively represents 1 16-bit sample // (store it in wf->nBlockAlign for the time being since init_audio() will // step on it anyway) if (sh_audio) sh_audio->wf->nBlockAlign = largest_audio_chunk * 2; roq_data->current_chunk = 0; demuxer->priv = roq_data; stream_reset(demuxer->stream); return demuxer; }
static demuxer_t* demux_open_vqf(demuxer_t* demuxer) { sh_audio_t* sh_audio; WAVEFORMATEX* w; stream_t *s; headerInfo *hi; s = demuxer->stream; sh_audio = new_sh_audio(demuxer,0, NULL); sh_audio->wf = w = malloc(sizeof(WAVEFORMATEX)+sizeof(headerInfo)); hi = (headerInfo *)&w[1]; memset(hi,0,sizeof(headerInfo)); w->wFormatTag = 0x1; sh_audio->format = mmioFOURCC('T','W','I','N'); /* TWinVQ */ w->nChannels = sh_audio->channels = 2; w->nSamplesPerSec = sh_audio->samplerate = 44100; w->nAvgBytesPerSec = w->nSamplesPerSec*sh_audio->channels*2; w->nBlockAlign = 0; sh_audio->samplesize = 2; w->wBitsPerSample = 8*sh_audio->samplesize; w->cbSize = 0; strcpy(hi->ID,"TWIN"); stream_read(s,hi->ID+KEYWORD_BYTES,VERSION_BYTES); /* fourcc+version_id */ while(1) { char chunk_id[4]; unsigned chunk_size; hi->size=chunk_size=stream_read_dword(s); /* include itself */ stream_read(s,chunk_id,4); if (chunk_size < 8) return NULL; chunk_size -= 8; if(AV_RL32(chunk_id)==mmioFOURCC('C','O','M','M')) { char buf[BUFSIZ]; unsigned i,subchunk_size; if (chunk_size > sizeof(buf) || chunk_size < 20) return NULL; if(stream_read(s,buf,chunk_size)!=chunk_size) return NULL; i=0; subchunk_size = AV_RB32(buf); hi->channelMode = AV_RB32(buf + 4); w->nChannels=sh_audio->channels=hi->channelMode+1; /*0-mono;1-stereo*/ hi->bitRate = AV_RB32(buf + 8); sh_audio->i_bps=hi->bitRate*1000/8; /* bitrate kbit/s */ w->nAvgBytesPerSec = sh_audio->i_bps; hi->samplingRate = AV_RB32(buf + 12); switch(hi->samplingRate){ case 44: w->nSamplesPerSec=44100; break; case 22: w->nSamplesPerSec=22050; break; case 11: w->nSamplesPerSec=11025; break; default: w->nSamplesPerSec=hi->samplingRate*1000; break; } sh_audio->samplerate=w->nSamplesPerSec; hi->securityLevel = AV_RB32(buf + 16); w->nBlockAlign = 0; sh_audio->samplesize = 4; w->wBitsPerSample = 8*sh_audio->samplesize; w->cbSize = 0; if (subchunk_size > chunk_size - 4) continue; i+=subchunk_size+4; while(i + 8 < chunk_size) { unsigned slen,sid; char sdata[BUFSIZ]; sid = AV_RL32(buf + i); i+=4; slen = AV_RB32(buf + i); i+=4; if (slen > sizeof(sdata) - 1 || slen > chunk_size - i) break; if(sid==mmioFOURCC('D','S','I','Z')) { hi->Dsiz=AV_RB32(buf + i); continue; /* describes the same info as size of DATA chunk */ } memcpy(sdata,&buf[i],slen); sdata[slen]=0; i+=slen; if(sid==mmioFOURCC('N','A','M','E')) { memcpy(hi->Name,sdata,FFMIN(BUFSIZ,slen)); demux_info_add(demuxer,"Title",sdata); } else if(sid==mmioFOURCC('A','U','T','H')) { memcpy(hi->Auth,sdata,FFMIN(BUFSIZ,slen)); demux_info_add(demuxer,"Author",sdata); } else if(sid==mmioFOURCC('C','O','M','T')) { memcpy(hi->Comt,sdata,FFMIN(BUFSIZ,slen)); demux_info_add(demuxer,"Comment",sdata); } else if(sid==mmioFOURCC('(','c',')',' ')) { memcpy(hi->Cpyr,sdata,FFMIN(BUFSIZ,slen)); demux_info_add(demuxer,"Copyright",sdata); } else if(sid==mmioFOURCC('F','I','L','E')) { memcpy(hi->File,sdata,FFMIN(BUFSIZ,slen)); } else if(sid==mmioFOURCC('A','L','B','M')) demux_info_add(demuxer,"Album",sdata); else if(sid==mmioFOURCC('Y','E','A','R')) demux_info_add(demuxer,"Date",sdata); else if(sid==mmioFOURCC('T','R','A','C')) demux_info_add(demuxer,"Track",sdata); else if(sid==mmioFOURCC('E','N','C','D')) demux_info_add(demuxer,"Encoder",sdata); else mp_msg(MSGT_DEMUX, MSGL_V, "Unhandled subchunk '%c%c%c%c'='%s'\n",((char *)&sid)[0],((char *)&sid)[1],((char *)&sid)[2],((char *)&sid)[3],sdata); /* other stuff is unrecognized due untranslatable japan's idiomatics */ } } else if(AV_RL32(chunk_id)==mmioFOURCC('D','A','T','A')) { demuxer->movi_start=stream_tell(s); demuxer->movi_end=demuxer->movi_start+chunk_size; mp_msg(MSGT_DEMUX, MSGL_V, "Found data at %"PRIX64" size %"PRIu64"\n",demuxer->movi_start,demuxer->movi_end); /* Done! play it */ break; } else { mp_msg(MSGT_DEMUX, MSGL_V, "Unhandled chunk '%c%c%c%c' %u bytes\n",chunk_id[0],chunk_id[1],chunk_id[2],chunk_id[3],chunk_size); stream_skip(s,chunk_size); /*unknown chunk type */ } } demuxer->audio->id = 0; demuxer->audio->sh = sh_audio; sh_audio->ds = demuxer->audio; stream_seek(s,demuxer->movi_start); demuxer->seekable=0; return demuxer; }
// return value: // 0 = EOF or no stream found // 1 = successfully read a packet static int demux_lmlm4_fill_buffer(demuxer_t *demux, demux_stream_t *ds) { FrameInfo frameInfo; double pts; int id=1; int ret; //hdr: demux->filepos = stream_tell(demux->stream); mp_msg(MSGT_DEMUX, MSGL_DBG2, "fpos = %"PRId64"\n", (int64_t)demux->filepos); ret=getFrame(demux, &frameInfo); if(ret<=0) return ret; // EOF/error pts=demux->video->sh ? frames*((sh_video_t*)(demux->video->sh))->frametime : 0; switch(frameInfo.frameType) { case FRAMETYPE_AUDIO_MPEG1L2: mp_dbg(MSGT_DEMUX, MSGL_DBG2, "Audio Packet\n"); if (!video) { stream_skip(demux->stream, frameInfo.frameSize + frameInfo.paddingSize); mp_msg(MSGT_DEMUX, MSGL_V, "Skip Audio Packet\n"); return -1; //goto hdr; } if(demux->audio->id==-1) { if(!demux->a_streams[id]) new_sh_audio(demux,id, NULL); demux->audio->id=id; demux->audio->sh=demux->a_streams[id]; ((sh_audio_t*)(demux->audio->sh))->format=0x50; // mpeg audio layer 1/2 } if(demux->audio->id==id) ds_read_packet(demux->audio, demux->stream, frameInfo.frameSize, pts, demux->filepos, 0); else stream_skip(demux->stream,frameInfo.frameSize); break; case FRAMETYPE_I: if (!video) { video = 1; mp_dbg(MSGT_DEMUX, MSGL_DBG2, "First Video Packet\n"); } case FRAMETYPE_P: frames=(frames+1)&(1024*1024-1); // wrap around at 4 hrs to avoid inaccurate float calculations if (!video) { stream_skip(demux->stream, frameInfo.frameSize + frameInfo.paddingSize); mp_msg(MSGT_DEMUX, MSGL_V, "Skip Video P Packet\n"); return -1; //goto hdr; } mp_dbg(MSGT_DEMUX, MSGL_DBG2, "Video Packet\n"); if(demux->video->id==-1) { if(!demux->v_streams[id]) new_sh_video(demux,id); demux->video->id=id; demux->video->sh=demux->v_streams[id]; ((sh_video_t*)(demux->video->sh))->format=0x10000004; // mpeg4-ES } if(demux->video->id==id) ds_read_packet(demux->video, demux->stream, frameInfo.frameSize, pts, demux->filepos, 0); break; default: stream_skip(demux->stream,frameInfo.frameSize); } stream_skip(demux->stream, frameInfo.paddingSize); return 1; }
static int demux_avi_read_packet(demuxer_t *demux,demux_stream_t *ds,unsigned int id,unsigned int len,int idxpos,int flags){ avi_priv_t *priv=demux->priv; int skip; float pts=0; mp_dbg(MSGT_DEMUX,MSGL_DBG3,"demux_avi.read_packet: %X\n",id); if(ds==demux->audio){ if(priv->pts_corrected==0){ if(priv->pts_has_video){ // we have video pts now float delay=0; if(((sh_audio_t*)(ds->sh))->wf->nAvgBytesPerSec) delay=(float)priv->pts_corr_bytes/((sh_audio_t*)(ds->sh))->wf->nAvgBytesPerSec; mp_msg(MSGT_DEMUX,MSGL_V,"XXX initial v_pts=%5.3f a_pos=%d (%5.3f) \n",priv->avi_audio_pts,priv->pts_corr_bytes,delay); //priv->pts_correction=-priv->avi_audio_pts+delay; priv->pts_correction=delay-priv->avi_audio_pts; priv->avi_audio_pts+=priv->pts_correction; priv->pts_corrected=1; } else priv->pts_corr_bytes+=len; } if(pts_from_bps){ pts = priv->audio_block_no * (float)((sh_audio_t*)demux->audio->sh)->audio.dwScale / (float)((sh_audio_t*)demux->audio->sh)->audio.dwRate; } else pts=priv->avi_audio_pts; //+priv->pts_correction; priv->avi_audio_pts=0; // update blockcount: priv->audio_block_no+=priv->audio_block_size ? ((len+priv->audio_block_size-1)/priv->audio_block_size) : 1; } else if(ds==demux->video){ // video if(priv->skip_video_frames>0){ // drop frame (seeking) --priv->skip_video_frames; ds=NULL; } pts = priv->avi_video_pts = priv->video_pack_no * (float)((sh_video_t*)demux->video->sh)->video.dwScale / (float)((sh_video_t*)demux->video->sh)->video.dwRate; priv->avi_audio_pts=priv->avi_video_pts+priv->pts_correction; priv->pts_has_video=1; if(ds) ++priv->video_pack_no; } skip=(len+1)&(~1); // total bytes in this chunk if(ds){ mp_dbg(MSGT_DEMUX,MSGL_DBG2,"DEMUX_AVI: Read %d data bytes from packet %04X\n",len,id); ds_read_packet(ds,demux->stream,len,pts,idxpos,flags); skip-=len; } skip = FFMAX(skip, 0); if (avi_stream_id(id) > 99 && id != mmioFOURCC('J','U','N','K')) skip = FFMIN(skip, 65536); if(skip){ mp_dbg(MSGT_DEMUX,MSGL_DBG2,"DEMUX_AVI: Skipping %d bytes from packet %04X\n",skip,id); stream_skip(demux->stream,skip); } return ds?1:0; }