if (!fmt || must_open_file) {
/* if no file needed do not try to open one */
- if (url_fopen(pb, filename, URL_RDONLY) < 0) {
- err = AVERROR_IO;
+ if ((err=url_fopen(pb, filename, URL_RDONLY)) < 0) {
goto fail;
}
file_opened = 1;
}
/* XXX: suppress this hack for redirectors */
-#ifdef CONFIG_NETWORK
+#ifdef CONFIG_REDIR_DEMUXER
if (fmt == &redir_demuxer) {
err = redir_open(ic_ptr, pb);
url_fclose(pb);
int av_read_packet(AVFormatContext *s, AVPacket *pkt)
{
+ av_init_packet(pkt);
return s->iformat->read_packet(s, pkt);
}
AVStream *st;
int len, ret, i;
+ av_init_packet(pkt);
+
for(;;) {
/* select current input stream component */
st = s->cur_st;
/* return packet if any */
if (pkt->size) {
got_packet:
+ pkt->pos = s->cur_pkt.pos; // Isn't quite accurate but close.
pkt->duration = 0;
pkt->stream_index = st->index;
pkt->pts = st->parser->pts;
st->parser = av_parser_init(st->codec->codec_id);
if (!st->parser) {
/* no parser available : just output the raw packets */
- st->need_parsing = 0;
- }else if(st->need_parsing == 2){
+ st->need_parsing = AVSTREAM_PARSE_NONE;
+ }else if(st->need_parsing == AVSTREAM_PARSE_HEADERS){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}
if(st->parser && (s->iformat->flags & AVFMT_GENERIC_INDEX)){
#ifdef DEBUG_SEEK
av_log(s, AV_LOG_DEBUG, "%"PRId64" %"PRId64" %"PRId64" / %"PRId64" %"PRId64" %"PRId64" target:%"PRId64" limit:%"PRId64" start:%"PRId64" noc:%d\n", pos_min, pos, pos_max, ts_min, ts, ts_max, target_ts, pos_limit, start_pos, no_change);
#endif
+ if(ts == AV_NOPTS_VALUE){
+ av_log(s, AV_LOG_ERROR, "read_timestamp() failed in the middle\n");
+ return -1;
+ }
assert(ts != AV_NOPTS_VALUE);
if (target_ts <= ts) {
pos_limit = start_pos - 1;
index = av_index_search_timestamp(st, timestamp, flags);
- if(index < 0){
+ if(index < 0 || index==st->nb_index_entries-1){
int i;
AVPacket pkt;
int64_t end_time;
int64_t filesize, offset, duration;
- av_read_frame_flush(ic);
+ /* free previous packet */
+ if (ic->cur_st && ic->cur_st->parser)
+ av_free_packet(&ic->cur_pkt);
+ ic->cur_st = NULL;
+
+ /* flush packet queue */
+ flush_packet_queue(ic);
+
+ for(i=0;i<ic->nb_streams;i++) {
+ st = ic->streams[i];
+ if (st->parser) {
+ av_parser_close(st->parser);
+ st->parser= NULL;
+ }
+ }
/* we read the first packets to get the first PTS (not fully
accurate, but it is enough now) */
else if (strncmp(fmt->name, "ac3", 3) == 0)
st->codec->codec_id = CODEC_ID_AC3;
}
- return fmt;
+ return !!fmt;
}
/* absolute maximum size we read until we abort */
//only for the split stuff
if (!st->parser) {
st->parser = av_parser_init(st->codec->codec_id);
- if(st->need_parsing == 2 && st->parser){
+ if(st->need_parsing == AVSTREAM_PARSE_HEADERS && st->parser){
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}
}
if (st->codec->codec_id == CODEC_ID_NONE) {
codec_identified[st->index] = set_codec_from_probe_data(st, &(probe_data[st->index]), 0);
if (codec_identified[st->index]) {
- st->need_parsing = 1;
+ st->need_parsing = AVSTREAM_PARSE_FULL;
}
}
if(!st->codec->bits_per_sample)
}
if(st->cur_dts && st->cur_dts != AV_NOPTS_VALUE && st->cur_dts >= pkt->dts){
- av_log(NULL, AV_LOG_ERROR, "error, non monotone timestamps %"PRId64" >= %"PRId64" st:%d\n", st->cur_dts, pkt->dts, st->index);
+ av_log(NULL, AV_LOG_ERROR, "error, non monotone timestamps %"PRId64" >= %"PRId64"\n", st->cur_dts, pkt->dts);
return -1;
}
if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts < pkt->dts){
- av_log(NULL, AV_LOG_ERROR, "error, pts < dts (%"PRId64" < %"PRId64")\n",
- pkt->pts, pkt->dts);
+ av_log(NULL, AV_LOG_ERROR, "error, pts < dts\n");
return -1;
}
{ "qcif", 176, 144, 0, 0 },
{ "cif", 352, 288, 0, 0 },
{ "4cif", 704, 576, 0, 0 },
+ { "qqvga", 160, 120, 0, 0 },
+ { "qvga", 320, 240, 0, 0 },
+ { "vga", 640, 480, 0, 0 },
+ { "svga", 800, 600, 0, 0 },
+ { "xga", 1024, 768, 0, 0 },
+ { "uxga", 1600,1200, 0, 0 },
+ { "qxga", 2048,1536, 0, 0 },
+ { "sxga", 1280,1024, 0, 0 },
+ { "qsxga", 2560,2048, 0, 0 },
+ { "hsxga", 5120,4096, 0, 0 },
+ { "wvga", 852, 480, 0, 0 },
+ { "wxga", 1366, 768, 0, 0 },
+ { "wsxga", 1600,1024, 0, 0 },
+ { "wuxga", 1920,1200, 0, 0 },
+ { "woxga", 2560,1600, 0, 0 },
+ { "wqsxga", 3200,2048, 0, 0 },
+ { "wquxga", 3840,2400, 0, 0 },
+ { "whsxga", 6400,4096, 0, 0 },
+ { "whuxga", 7680,4800, 0, 0 },
+ { "cga", 320, 200, 0, 0 },
+ { "ega", 640, 350, 0, 0 },
+ { "hd480", 852, 480, 0, 0 },
+ { "hd720", 1280, 720, 0, 0 },
+ { "hd1080", 1920,1080, 0, 0 },
};
int parse_image_size(int *width_ptr, int *height_ptr, const char *str)
return 0;
}
-#ifndef CONFIG_WINCE
int64_t parse_date(const char *datestr, int duration)
{
const char *p;
}
return negative ? -t : t;
}
-#endif /* CONFIG_WINCE */
int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
{