const char *avformat_license(void)
{
#define LICENSE_PREFIX "libavformat license: "
- return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
+ return &LICENSE_PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1];
}
int ff_lock_avformat(void)
* Return the number of bytes read or an error. */
static int append_packet_chunked(AVIOContext *s, AVPacket *pkt, int size)
{
- int64_t orig_pos = pkt->pos; // av_grow_packet might reset pos
int orig_size = pkt->size;
int ret;
if (size > 0)
pkt->flags |= AV_PKT_FLAG_CORRUPT;
- pkt->pos = orig_pos;
if (!pkt->size)
av_packet_unref(pkt);
return pkt->size > orig_size ? pkt->size - orig_size : ret;
level = AV_LOG_ERROR;
av_log(s, level, "Discarding ID3 tags because more suitable tags were found.\n");
av_dict_free(&s->internal->id3v2_meta);
- if (s->error_recognition & AV_EF_EXPLODE)
- return AVERROR_INVALIDDATA;
+ if (s->error_recognition & AV_EF_EXPLODE) {
+ ret = AVERROR_INVALIDDATA;
+ goto close;
+ }
}
if (id3v2_extra_meta) {
if (!strcmp(s->iformat->name, "mp3") || !strcmp(s->iformat->name, "aac") ||
!strcmp(s->iformat->name, "tta") || !strcmp(s->iformat->name, "wav")) {
if ((ret = ff_id3v2_parse_apic(s, &id3v2_extra_meta)) < 0)
- goto fail;
+ goto close;
if ((ret = ff_id3v2_parse_chapters(s, &id3v2_extra_meta)) < 0)
- goto fail;
+ goto close;
if ((ret = ff_id3v2_parse_priv(s, &id3v2_extra_meta)) < 0)
- goto fail;
+ goto close;
} else
av_log(s, AV_LOG_DEBUG, "demuxer does not support additional id3 data, skipping\n");
}
ff_id3v2_free_extra_meta(&id3v2_extra_meta);
if ((ret = avformat_queue_attached_pictures(s)) < 0)
- goto fail;
+ goto close;
if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->pb && !s->internal->data_offset)
s->internal->data_offset = avio_tell(s->pb);
*ps = s;
return 0;
+close:
+ if (s->iformat->read_close)
+ s->iformat->read_close(s);
fail:
ff_id3v2_free_extra_meta(&id3v2_extra_meta);
av_dict_free(&tmp);
return err;
}
- if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT) &&
- (pkt->flags & AV_PKT_FLAG_CORRUPT)) {
+ if (pkt->flags & AV_PKT_FLAG_CORRUPT) {
av_log(s, AV_LOG_WARNING,
- "Dropped corrupted packet (stream = %d)\n",
- pkt->stream_index);
- av_packet_unref(pkt);
- continue;
+ "Packet corrupt (stream = %d, dts = %s)",
+ pkt->stream_index, av_ts2str(pkt->dts));
+ if (s->flags & AVFMT_FLAG_DISCARD_CORRUPT) {
+ av_log(s, AV_LOG_WARNING, ", dropping it.\n");
+ av_packet_unref(pkt);
+ continue;
+ }
+ av_log(s, AV_LOG_WARNING, ".\n");
}
av_assert0(pkt->stream_index < (unsigned)s->nb_streams &&
//We could use URLProtocol flags here but as many user applications do not use URLProtocols this would be unreliable
const char *proto = avio_find_protocol_name(s->url);
+ av_assert0(time_tolerance >= 0);
+
if (!proto) {
av_log(s, AV_LOG_INFO,
"Protocol name not provided, cannot determine if input is local or "
for (; i2 < st2->nb_index_entries; i2++) {
AVIndexEntry *e2 = &st2->index_entries[i2];
int64_t e2_pts = av_rescale_q(e2->timestamp, st2->time_base, AV_TIME_BASE_Q);
- if (e2_pts - e1_pts < time_tolerance)
+ if (e2_pts < e1_pts || e2_pts - (uint64_t)e1_pts < time_tolerance)
continue;
pos_delta = FFMAX(pos_delta, e1->pos - e2->pos);
break;
char *hostname, int hostname_size,
int *port_ptr, char *path, int path_size, const char *url)
{
- const char *p, *ls, *ls2, *at, *at2, *col, *brk;
+ const char *p, *ls, *at, *at2, *col, *brk;
if (port_ptr)
*port_ptr = -1;
}
/* separate path from hostname */
- ls = strchr(p, '/');
- ls2 = strchr(p, '?');
- if (!ls)
- ls = ls2;
- else if (ls && ls2)
- ls = FFMIN(ls, ls2);
- if (ls)
- av_strlcpy(path, ls, path_size);
- else
- ls = &p[strlen(p)]; // XXX
+ ls = p + strcspn(p, "/?#");
+ av_strlcpy(path, ls, path_size);
/* the rest is hostname, use that to parse auth/port */
if (ls != p) {
};
const uint8_t *data = NULL;
- int size = 0;
+ int ret, size = 0;
if (st->codecpar->width == 1920) {
if (st->codecpar->field_order == AV_FIELD_PROGRESSIVE) {
if (!size)
return 0;
- av_freep(&st->codecpar->extradata);
- if (ff_alloc_extradata(st->codecpar, size))
- return AVERROR(ENOMEM);
+ if ((ret = ff_alloc_extradata(st->codecpar, size)) < 0)
+ return ret;
memcpy(st->codecpar->extradata, data, size);
return 0;