static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
AVStream *st;
- int id;
+ enum CodecID id;
st = av_new_stream(s, 0);
if (!st)
id = s->iformat->value;
if (id == CODEC_ID_RAWVIDEO) {
- st->codec->codec_type = CODEC_TYPE_VIDEO;
+ st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
} else {
- st->codec->codec_type = CODEC_TYPE_AUDIO;
+ st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
}
st->codec->codec_id = id;
switch(st->codec->codec_type) {
- case CODEC_TYPE_AUDIO:
+ case AVMEDIA_TYPE_AUDIO:
st->codec->sample_rate = ap->sample_rate;
if(ap->channels) st->codec->channels = ap->channels;
else st->codec->channels = 1;
st->codec->block_align = st->codec->bits_per_coded_sample*st->codec->channels/8;
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
break;
- case CODEC_TYPE_VIDEO:
+ case AVMEDIA_TYPE_VIDEO:
if(ap->time_base.num)
av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
else
ret= av_get_packet(s->pb, pkt, size);
pkt->stream_index = 0;
- if (ret <= 0) {
- return AVERROR(EIO);
- }
- /* note: we need to modify the packet size here to handle the last
- packet */
- pkt->size = ret;
+ if (ret < 0)
+ return ret;
bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id);
assert(bps); // if false there IS a bug elsewhere (NOT in this function)
size = RAW_PACKET_SIZE;
if (av_new_packet(pkt, size) < 0)
- return AVERROR(EIO);
+ return AVERROR(ENOMEM);
pkt->pos= url_ftell(s->pb);
pkt->stream_index = 0;
ret = get_partial_buffer(s->pb, pkt->data, size);
- if (ret <= 0) {
+ if (ret < 0) {
av_free_packet(pkt);
- return AVERROR(EIO);
+ return ret;
}
pkt->size = ret;
return ret;
pkt->dts= pkt->pos / packet_size;
pkt->stream_index = 0;
- if (ret != packet_size) {
- return AVERROR(EIO);
- } else {
- return 0;
- }
+ if (ret < 0)
+ return ret;
+ return 0;
}
#endif
size, w, h, unk1, unk2);
if (av_new_packet(pkt, size) < 0)
- return AVERROR(EIO);
+ return AVERROR(ENOMEM);
pkt->pos = url_ftell(s->pb);
pkt->stream_index = 0;
ret = get_buffer(s->pb, pkt->data, size);
- if (ret <= 0) {
+ if (ret < 0) {
av_free_packet(pkt);
- return AVERROR(EIO);
+ return ret;
}
pkt->size = ret;
return ret;
int stream_index, int64_t timestamp, int flags)
{
AVStream *st;
- int block_align, byte_rate, ret;
- int64_t pos;
+ int block_align, byte_rate;
+ int64_t pos, ret;
st = s->streams[0];
AVStream *st = av_new_stream(s, 0);
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = CODEC_TYPE_AUDIO;
+ st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = s->iformat->value;
st->need_parsing = AVSTREAM_PARSE_FULL;
/* the parameters will be extracted from the compressed bitstream */
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = CODEC_TYPE_VIDEO;
+ st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = s->iformat->value;
st->need_parsing = AVSTREAM_PARSE_FULL;
} else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
st->codec->codec_id == CODEC_ID_MPEG4 ||
st->codec->codec_id == CODEC_ID_DIRAC ||
+ st->codec->codec_id == CODEC_ID_DNXHD ||
st->codec->codec_id == CODEC_ID_H264) {
st->codec->time_base= (AVRational){1,25};
}
last_src_fmt= src_fmt;
}
}
- if(valid_psc > 2*invalid_psc + 2*res_change + 2){
+//av_log(NULL, AV_LOG_ERROR, "h263_probe: psc:%d invalid:%d res_change:%d\n", valid_psc, invalid_psc, res_change);
+//h263_probe: psc:3 invalid:0 res_change:0 (1588/recent_ffmpeg_parses_mpg_incorrectly.mpg)
+ if(valid_psc > 2*invalid_psc + 2*res_change + 3){
return 50;
}else if(valid_psc > 2*invalid_psc)
return 25;
init_get_bits(&gb, p->buf, p->buf_size*8);
for(i=0; i<p->buf_size*8; i++){
- code = (code<<1) + get_bits1(&gb);
+ if ((code & 0x01ff0000) || !(code & 0xff00)) {
+ code = (code<<8) + get_bits(&gb, 8);
+ i += 7;
+ } else
+ code = (code<<1) + get_bits1(&gb);
if ((code & 0xffff0000) == 0x10000) {
int gn= (code>>12)&0xf;
if(!gn)
first_frames = frames;
}
if(codec_id != expected_codec_id) return 0;
- if (first_frames>=3) return AVPROBE_SCORE_MAX * 3 / 4;
- else if(max_frames>=3) return AVPROBE_SCORE_MAX / 2;
+ // keep this in sync with mp3 probe, both need to avoid
+ // issues with MPEG-files!
+ if (first_frames>=4) return AVPROBE_SCORE_MAX/2+1;
+ else if(max_frames>500)return AVPROBE_SCORE_MAX/2;
+ else if(max_frames>=4) return AVPROBE_SCORE_MAX/4;
else if(max_frames>=1) return 1;
else return 0;
}
if (!st)
return AVERROR(ENOMEM);
- st->codec->codec_type = CODEC_TYPE_AUDIO;
+ st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = s->iformat->value;
st->need_parsing = AVSTREAM_PARSE_FULL;