ffmpeg: remove old patches

This commit is contained in:
Stefan Saraev 2013-12-09 11:21:05 +02:00
parent 6a4ec6f637
commit f0ad9cdf8a
45 changed files with 0 additions and 9008 deletions

View File

@ -1,56 +0,0 @@
From 5d361593f1149c2c0874d76a27c5cc68a219088c Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Sun, 11 Sep 2011 19:04:51 +0200
Subject: [PATCH 01/24] Support raw dvdsub palette as stored on normal dvd's
This is how the palette is stored on dvd's. Currently
only xbmc passes the palette information to libavcodec
this way.
---
libavcodec/dvdsubdec.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index f4b5439..d0d13ee 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -50,6 +50,24 @@ static void yuv_a_to_rgba(const uint8_t *ycbcr, const uint8_t *alpha, uint32_t *
}
}
+static void ayvu_to_argb(const uint8_t *ayvu, uint32_t *argb, int num_values)
+{
+ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+ uint8_t r, g, b;
+ int i, y, cb, cr, a;
+ int r_add, g_add, b_add;
+
+ for (i = num_values; i > 0; i--) {
+ a = *ayvu++;
+ y = *ayvu++;
+ cr = *ayvu++;
+ cb = *ayvu++;
+ YUV_TO_RGB1_CCIR(cb, cr);
+ YUV_TO_RGB2_CCIR(r, g, b, y);
+ *argb++ = (a << 24) | (r << 16) | (g << 8) | b;
+ }
+}
+
static int decode_run_2bit(GetBitContext *gb, int *color)
{
unsigned int v, t;
@@ -547,6 +565,11 @@ static int dvdsub_init(AVCodecContext *avctx)
data += strspn(data, "\n\r");
}
+ if (!ctx->has_palette && avctx->extradata_size == 64) {
+ ayvu_to_argb((uint8_t*)avctx->extradata, ctx->palette, 16);
+ ctx->has_palette = 1;
+ }
+
if (ctx->has_palette) {
int i;
av_log(avctx, AV_LOG_DEBUG, "palette:");
--
1.7.9.4

View File

@ -1,145 +0,0 @@
From 8b480b7321130ad691cf46314164787301691161 Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Mon, 12 Sep 2011 23:53:29 +0200
Subject: [PATCH 02/24] Change fallthrough logic for read_seek to be based on
return value
This changes the logic for read_seek to only use generic seek
rutines if the return value is AVERROR(ENOSYS) to avoid retrying
seeks if the demuxer already realized it wasn't possible.
---
libavformat/asfdec.c | 2 +-
libavformat/gxf.c | 4 ++--
libavformat/jvdec.c | 2 +-
libavformat/matroskadec.c | 2 +-
libavformat/oggdec.c | 4 +++-
libavformat/pmpdec.c | 2 +-
libavformat/r3d.c | 2 +-
libavformat/utils.c | 4 +++-
8 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 0deafc6..a62bab3 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -1278,7 +1278,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int
AVStream *st = s->streams[stream_index];
if (s->packet_size <= 0)
- return -1;
+ return AVERROR(ENOSYS);
/* Try using the protocol's read_seek if available */
if(s->pb) {
diff --git a/libavformat/gxf.c b/libavformat/gxf.c
index e773ba7..a3298a7 100644
--- a/libavformat/gxf.c
+++ b/libavformat/gxf.c
@@ -542,7 +542,7 @@ static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int
idx = av_index_search_timestamp(st, timestamp - start_time,
AVSEEK_FLAG_ANY | AVSEEK_FLAG_BACKWARD);
if (idx < 0)
- return -1;
+ return AVERROR(ENOSYS);
pos = st->index_entries[idx].pos;
if (idx < st->nb_index_entries - 2)
maxlen = st->index_entries[idx + 2].pos - pos;
@@ -552,7 +552,7 @@ static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int
return res;
found = gxf_resync_media(s, maxlen, -1, timestamp);
if (FFABS(found - timestamp) > 4)
- return -1;
+ return AVERROR(ENOSYS);
return 0;
}
diff --git a/libavformat/jvdec.c b/libavformat/jvdec.c
index 212cd8a..d52060b 100644
--- a/libavformat/jvdec.c
+++ b/libavformat/jvdec.c
@@ -207,7 +207,7 @@ static int read_seek(AVFormatContext *s, int stream_index,
}
if (i < 0 || i >= ast->nb_index_entries)
- return 0;
+ return -1;
if (avio_seek(s->pb, ast->index_entries[i].pos, SEEK_SET) < 0)
return -1;
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 2787a17..135fddd 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2048,7 +2048,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
}
if (!st->nb_index_entries)
- return 0;
+ return -1;
timestamp = FFMAX(timestamp, st->index_entries[0].timestamp);
if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index ceb4091..80669a5 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -663,8 +663,10 @@ static int ogg_read_seek(AVFormatContext *s, int stream_index,
ret = ff_seek_frame_binary(s, stream_index, timestamp, flags);
os = ogg->streams + stream_index;
- if (ret < 0)
+ if (ret < 0) {
os->keyframe_seek = 0;
+ ret = AVERROR(ENOSYS);
+ }
return ret;
}
diff --git a/libavformat/pmpdec.c b/libavformat/pmpdec.c
index a57b660..9db4e26 100644
--- a/libavformat/pmpdec.c
+++ b/libavformat/pmpdec.c
@@ -157,7 +157,7 @@ static int pmp_seek(AVFormatContext *s, int stream_index, int64_t ts, int flags)
PMPContext *pmp = s->priv_data;
pmp->cur_stream = 0;
// fallback to default seek now
- return -1;
+ return AVERROR(ENOSYS);
}
static int pmp_close(AVFormatContext *s)
diff --git a/libavformat/r3d.c b/libavformat/r3d.c
index 874c361..0adad72 100644
--- a/libavformat/r3d.c
+++ b/libavformat/r3d.c
@@ -358,7 +358,7 @@ static int r3d_seek(AVFormatContext *s, int stream_index, int64_t sample_time, i
int frame_num;
if (!st->codec->time_base.num || !st->time_base.den)
- return -1;
+ return AVERROR(ENOSYS);
frame_num = sample_time*st->codec->time_base.den/
((int64_t)st->codec->time_base.num*st->time_base.den);
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 9164cd0..242d616 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1910,11 +1910,13 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int f
ff_read_frame_flush(s);
ret = s->iformat->read_seek(s, stream_index, timestamp, flags);
} else
- ret = -1;
+ ret = AVERROR(ENOSYS);
)
if (ret >= 0) {
return 0;
}
+ if (ret != AVERROR(ENOSYS))
+ return ret;
if (s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH)) {
ff_read_frame_flush(s);
--
1.7.9.4

View File

@ -1,64 +0,0 @@
From a8a72d52860df38f3a126ca544663f9ea379a929 Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Sat, 22 Oct 2011 18:33:45 +0200
Subject: [PATCH 03/24] [matroska] Check return value of avio_seek and avoid
modifying state if it fails
The code still modifies state if the timestamp is not found. Not
sure exactly how to avoid that.
---
libavformat/matroskadec.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 135fddd..a9a0d1f 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2052,7 +2052,8 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
timestamp = FFMAX(timestamp, st->index_entries[0].timestamp);
if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
- avio_seek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET);
+ if (avio_seek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET) < 0)
+ return -1;
matroska->current_id = 0;
while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
matroska_clear_queue(matroska);
@@ -2061,16 +2062,11 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
}
}
- matroska_clear_queue(matroska);
if (index < 0)
return 0;
index_min = index;
for (i=0; i < matroska->tracks.nb_elem; i++) {
- tracks[i].audio.pkt_cnt = 0;
- tracks[i].audio.sub_packet_cnt = 0;
- tracks[i].audio.buf_timecode = AV_NOPTS_VALUE;
- tracks[i].end_timecode = 0;
if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE
&& !tracks[i].stream->discard != AVDISCARD_ALL) {
index_sub = av_index_search_timestamp(tracks[i].stream, st->index_entries[index].timestamp, AVSEEK_FLAG_BACKWARD);
@@ -2081,7 +2077,16 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
}
}
- avio_seek(s->pb, st->index_entries[index_min].pos, SEEK_SET);
+ if (avio_seek(s->pb, st->index_entries[index_min].pos, SEEK_SET) < 0)
+ return -1;
+
+ matroska_clear_queue(matroska);
+ for (i=0; i < matroska->tracks.nb_elem; i++) {
+ tracks[i].audio.pkt_cnt = 0;
+ tracks[i].audio.sub_packet_cnt = 0;
+ tracks[i].audio.buf_timecode = AV_NOPTS_VALUE;
+ tracks[i].end_timecode = 0;
+ }
matroska->current_id = 0;
matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY);
matroska->skip_to_timecode = st->index_entries[index].timestamp;
--
1.7.9.4

View File

@ -1,37 +0,0 @@
From 16ed0150800958b4ca544fd380bda92f21393555 Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Mon, 12 Sep 2011 21:37:17 +0200
Subject: [PATCH 04/24] asf hacks
---
libavformat/asfdec.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index a62bab3..7db3bd8 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -1277,9 +1277,20 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int
ASFContext *asf = s->priv_data;
AVStream *st = s->streams[stream_index];
+ if (pts == 0) {
+ // this is a hack since av_gen_search searches the entire file in this case
+ av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", s->data_offset);
+ if (avio_seek(s->pb, s->data_offset, SEEK_SET) < 0)
+ return -1;
+ return 0;
+ }
+
if (s->packet_size <= 0)
return AVERROR(ENOSYS);
+ if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO)
+ return -1;
+
/* Try using the protocol's read_seek if available */
if(s->pb) {
int ret = avio_seek_time(s->pb, stream_index, pts, flags);
--
1.7.9.4

View File

@ -1,27 +0,0 @@
From 55467e617c4772441e128cfcc3939beafdd8bf8a Mon Sep 17 00:00:00 2001
From: Cory Fields <theuni-nospam-@xbmc.org>
Date: Mon, 28 Jun 2010 01:55:31 -0400
Subject: [PATCH 05/24] if av_read_packet returns AVERROR_IO, we are done.
ffmpeg's codecs might or might not handle returning
any completed demuxed packets correctly
---
libavformat/utils.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 242d616..ebb8493 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1248,6 +1248,8 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
if (ret < 0) {
if (ret == AVERROR(EAGAIN))
return ret;
+ if (ret == AVERROR(EIO))
+ return ret;
/* return the last frames, if any */
for(i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
--
1.7.9.4

View File

@ -1,42 +0,0 @@
From 406e25be924a32d5df14a977e8b9694a767f6378 Mon Sep 17 00:00:00 2001
From: Cory Fields <theuni-nospam-@xbmc.org>
Date: Mon, 28 Jun 2010 02:10:50 -0400
Subject: [PATCH 06/24] added: Ticket #7187, TV Teletext support for DVB EBU
Teletext streams
---
libavcodec/avcodec.h | 4 ++++
libavformat/mpegts.c | 2 ++
2 files changed, 6 insertions(+)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 81849c1..0b756d0 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -425,6 +425,10 @@ enum CodecID {
CODEC_ID_SRT,
CODEC_ID_MICRODVD = MKBETAG('m','D','V','D'),
+ /* data codecs */
+ CODEC_ID_VBI_DATA= 0x17500,
+ CODEC_ID_VBI_TELETEXT,
+
/* other specific kind of codecs (generally used for attachments) */
CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
CODEC_ID_TTF = 0x18000,
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 9998248..e7e061e 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -581,6 +581,8 @@ static const StreamType DESC_types[] = {
{ 0x7b, AVMEDIA_TYPE_AUDIO, CODEC_ID_DTS },
{ 0x56, AVMEDIA_TYPE_SUBTITLE, CODEC_ID_DVB_TELETEXT },
{ 0x59, AVMEDIA_TYPE_SUBTITLE, CODEC_ID_DVB_SUBTITLE }, /* subtitling descriptor */
+ { 0x45, AVMEDIA_TYPE_DATA, CODEC_ID_VBI_DATA }, /* VBI Data descriptor */
+ { 0x46, AVMEDIA_TYPE_DATA, CODEC_ID_VBI_TELETEXT }, /* VBI Teletext descriptor */
{ 0 },
};
--
1.7.9.4

View File

@ -1,41 +0,0 @@
From 3bf21b1049abf8991beac79235adfcca9d705eda Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Sun, 18 Sep 2011 19:16:34 +0200
Subject: [PATCH 07/24] Don't accept mpegts PMT that isn't current
---
libavformat/mpegts.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index e7e061e..817fbed 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -437,6 +437,7 @@ typedef struct SectionHeader {
uint8_t tid;
uint16_t id;
uint8_t version;
+ uint8_t current;
uint8_t sec_num;
uint8_t last_sec_num;
} SectionHeader;
@@ -508,6 +509,7 @@ static int parse_section_header(SectionHeader *h,
val = get8(pp, p_end);
if (val < 0)
return -1;
+ h->current = val & 0x1;
h->version = (val >> 1) & 0x1f;
val = get8(pp, p_end);
if (val < 0)
@@ -1556,6 +1558,8 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
return;
if (h->tid != PAT_TID)
return;
+ if (!h->current)
+ return;
ts->stream->ts_id = h->id;
--
1.7.9.4

View File

@ -1,43 +0,0 @@
From 5fecd135de1486be63e0cef53134c44f8b4becd6 Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Sun, 18 Sep 2011 19:17:23 +0200
Subject: [PATCH 08/24] Don't reparse PMT unless it's version has changed
---
libavformat/mpegts.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 817fbed..8bdafc5 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -78,6 +78,7 @@ struct MpegTSFilter {
int pid;
int es_id;
int last_cc; /* last cc code (-1 if first packet) */
+ int last_version; /* last version of data on this pid */
enum MpegTSFilterType type;
union {
MpegTSPESFilter pes_filter;
@@ -334,6 +335,7 @@ static MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts, unsigned int
filter->pid = pid;
filter->es_id = -1;
filter->last_cc = -1;
+ filter->last_version = -1;
sec = &filter->u.section_filter;
sec->section_cb = section_cb;
sec->opaque = opaque;
@@ -1560,6 +1562,10 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
return;
if (!h->current)
return;
+ if (h->version == filter->last_version)
+ return;
+ filter->last_version = h->version;
+ av_dlog(ts->stream, "version=%d\n", filter->last_version);
ts->stream->ts_id = h->id;
--
1.7.9.4

View File

@ -1,63 +0,0 @@
From 13fa8f2299e51192354cfb468dc05452ab9c9e4e Mon Sep 17 00:00:00 2001
From: Cory Fields <theuni-nospam-@xbmc.org>
Date: Mon, 28 Jun 2010 03:04:26 -0400
Subject: [PATCH 09/24] fixed: compile with VDPAU header versions without
MPEG4 support.
See http://repo.or.cz/w/FFMpeg-mirror/mplayer-patches.git/commitdiff/136c16af11076153717d3de31c9d84360644e006
---
configure | 2 ++
libavcodec/vdpau.c | 2 ++
libavcodec/vdpau.h | 2 ++
3 files changed, 6 insertions(+)
diff --git a/configure b/configure
index 07d473e..6255f57 100755
--- a/configure
+++ b/configure
@@ -3058,6 +3058,8 @@ check_header sys/select.h
check_header termios.h
check_header vdpau/vdpau.h
check_header vdpau/vdpau_x11.h
+check_cpp_condition vdpau/vdpau.h "defined(VDP_DECODER_PROFILE_MPEG4_PART2_SP)" && enable vdpau_mpeg4_support
+
check_header X11/extensions/XvMClib.h
check_header asm/types.h
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index ce5103a..21b4fc9 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -316,6 +316,7 @@ void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
render->bitstream_buffers_used = 0;
}
+#ifdef VDP_DECODER_PROFILE_MPEG4_PART2_SP
void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
int buf_size)
{
@@ -369,6 +370,7 @@ void ff_vdpau_mpeg4_decode_picture(MpegEncContext *s, const uint8_t *buf,
ff_draw_horiz_band(s, 0, s->avctx->height);
render->bitstream_buffers_used = 0;
}
+#endif
// Only dummy functions for now
static int vdpau_mpeg2_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
diff --git a/libavcodec/vdpau.h b/libavcodec/vdpau.h
index f3a5471..3748675 100644
--- a/libavcodec/vdpau.h
+++ b/libavcodec/vdpau.h
@@ -79,7 +79,9 @@ struct vdpau_render_state {
VdpPictureInfoH264 h264;
VdpPictureInfoMPEG1Or2 mpeg;
VdpPictureInfoVC1 vc1;
+#ifdef VDP_DECODER_PROFILE_MPEG4_PART2_SP
VdpPictureInfoMPEG4Part2 mpeg4;
+#endif
} info;
};
--
1.7.9.4

View File

@ -1,100 +0,0 @@
From 17c6bca0f47b1a0c3deac3ad948cdd674c135321 Mon Sep 17 00:00:00 2001
From: Cory Fields <theuni-nospam-@xbmc.org>
Date: Fri, 9 Jul 2010 16:43:31 -0400
Subject: [PATCH 10/24] Read PID timestamps as well as PCR timestamps to find
location in mpegts stream
---
libavformat/mpegts.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 8bdafc5..ba2f163 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1928,6 +1928,44 @@ static int parse_pcr(int64_t *ppcr_high, int *ppcr_low,
return 0;
}
+static int parse_timestamp(int64_t *ts, const uint8_t *buf)
+{
+ int afc, flags;
+ const uint8_t *p;
+
+ if(!(buf[1] & 0x40)) /* must be a start packet */
+ return -1;
+
+ afc = (buf[3] >> 4) & 3;
+ p = buf + 4;
+ if (afc == 0 || afc == 2) /* invalid or only adaption field */
+ return -1;
+ if (afc == 3)
+ p += p[0] + 1;
+ if (p >= buf + TS_PACKET_SIZE)
+ return -1;
+
+ if (p[0] != 0x00 || p[1] != 0x00 || p[2] != 0x01) /* packet_start_code_prefix */
+ return -1;
+
+ flags = p[3] | 0x100; /* stream type */
+ if (!((flags >= 0x1c0 && flags <= 0x1df) ||
+ (flags >= 0x1e0 && flags <= 0x1ef) ||
+ (flags == 0x1bd) || (flags == 0x1fd)))
+ return -1;
+
+ flags = p[7];
+ if ((flags & 0xc0) == 0x80) {
+ *ts = ff_parse_pes_pts(p+9);
+ return 0;
+ } else if ((flags & 0xc0) == 0xc0) {
+ *ts = ff_parse_pes_pts(p+9+5);
+ return 0;
+ }
+ return -1;
+}
+
+
static int mpegts_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
@@ -2118,6 +2156,7 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
int64_t pos, timestamp;
uint8_t buf[TS_PACKET_SIZE];
int pcr_l, pcr_pid = ((PESContext*)s->streams[stream_index]->priv_data)->pcr_pid;
+ int pid = ((PESContext*)s->streams[stream_index]->priv_data)->pid;
pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47;
while(pos < pos_limit) {
if (avio_seek(s->pb, pos, SEEK_SET) < 0)
@@ -2135,6 +2174,11 @@ static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
*ppos = pos;
return timestamp;
}
+ if ((pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pid) &&
+ parse_timestamp(&timestamp, buf) == 0) {
+ *ppos = pos;
+ return timestamp;
+ }
pos += ts->raw_packet_size;
}
@@ -2322,7 +2366,7 @@ AVInputFormat ff_mpegts_demuxer = {
.read_header = mpegts_read_header,
.read_packet = mpegts_read_packet,
.read_close = mpegts_read_close,
- .read_timestamp = mpegts_get_dts,
+ .read_timestamp = mpegts_get_pcr,
.flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT,
#ifdef USE_SYNCPOINT_SEARCH
.read_seek2 = read_seek2,
@@ -2336,7 +2380,7 @@ AVInputFormat ff_mpegtsraw_demuxer = {
.read_header = mpegts_read_header,
.read_packet = mpegts_raw_read_packet,
.read_close = mpegts_read_close,
- .read_timestamp = mpegts_get_dts,
+ .read_timestamp = mpegts_get_pcr,
.flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT,
#ifdef USE_SYNCPOINT_SEARCH
.read_seek2 = read_seek2,
--
1.7.9.4

View File

@ -1,69 +0,0 @@
From 95926a84fe1369f796c916f72c50dd5b7d50b15a Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Sat, 22 Oct 2011 19:01:38 +0200
Subject: [PATCH 11/24] Get stream durations using read_timestamp
---
libavformat/utils.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index ebb8493..25fe38e 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2082,6 +2082,41 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic)
#define DURATION_MAX_READ_SIZE 250000
#define DURATION_MAX_RETRY 3
+static void av_estimate_timings_from_pts2(AVFormatContext *ic, int64_t old_offset)
+{
+ AVStream *st;
+ int i, step= 1024;
+ int64_t ts, pos;
+
+ for(i=0;i<ic->nb_streams;i++) {
+ st = ic->streams[i];
+
+ pos = 0;
+ ts = ic->iformat->read_timestamp(ic, i, &pos, DURATION_MAX_READ_SIZE);
+ if (ts == AV_NOPTS_VALUE)
+ continue;
+ if (st->start_time > ts || st->start_time == AV_NOPTS_VALUE)
+ st->start_time = ts;
+
+ pos = url_fsize(ic->pb) - 1;
+ do {
+ pos -= step;
+ ts = ic->iformat->read_timestamp(ic, i, &pos, pos + step);
+ step += step;
+ } while (ts == AV_NOPTS_VALUE && pos >= step && step < DURATION_MAX_READ_SIZE);
+
+ if (ts == AV_NOPTS_VALUE)
+ continue;
+
+ if (st->duration < ts - st->start_time || st->duration == AV_NOPTS_VALUE)
+ st->duration = ts - st->start_time;
+ }
+
+ fill_all_stream_timings(ic);
+
+ avio_seek(ic->pb, old_offset, SEEK_SET);
+}
+
/* only usable for MPEG-PS streams */
static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
{
@@ -2184,6 +2219,10 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
/* at least one component has timings - we use them for all
the components */
fill_all_stream_timings(ic);
+ } else if (ic->iformat->read_timestamp &&
+ file_size && ic->pb->seekable) {
+ /* get accurate estimate from the PTSes */
+ av_estimate_timings_from_pts2(ic, old_offset);
} else {
av_log(ic, AV_LOG_WARNING, "Estimating duration from bitrate, this may be inaccurate\n");
/* less precise: use bitrate info */
--
1.7.9.4

View File

@ -1,24 +0,0 @@
From eaa6256c161f1f6d48b222b171f68869dace8f3f Mon Sep 17 00:00:00 2001
From: Cory Fields <theuni-nospam-@xbmc.org>
Date: Fri, 9 Jul 2010 16:49:01 -0400
Subject: [PATCH 12/24] include stdint.h
---
libavutil/common.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/libavutil/common.h b/libavutil/common.h
index 84290c6..5b73579 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -29,6 +29,7 @@
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
+#include <stdint.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
--
1.7.9.4

View File

@ -1,35 +0,0 @@
From 8728e8bdef30313f1961d2687cfb0ffccf540797 Mon Sep 17 00:00:00 2001
From: Anssi Hannula <anssi.hannula@iki.fi>
Date: Fri, 21 Jan 2011 20:44:02 +0200
Subject: [PATCH 13/24] aacenc: add recognized profiles array
Submitted upstream.
---
libavcodec/aacenc.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 2ff6f9c..4ffaa3d 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -777,6 +777,11 @@ static const AVClass aacenc_class = {
LIBAVUTIL_VERSION_INT,
};
+static const AVProfile profiles[] = {
+ { FF_PROFILE_AAC_LOW, "Low" },
+ { FF_PROFILE_UNKNOWN },
+};
+
AVCodec ff_aac_encoder = {
.name = "aac",
.type = AVMEDIA_TYPE_AUDIO,
@@ -789,4 +794,5 @@ AVCodec ff_aac_encoder = {
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"),
.priv_class = &aacenc_class,
+ .profiles = profiles,
};
--
1.7.9.4

View File

@ -1,28 +0,0 @@
From 5cc735503bfe1242606f19638bffeb686dd4d1b5 Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Wed, 8 Dec 2010 14:03:43 +0000
Subject: [PATCH 14/24] changed: allow 4 second skew between streams in mov
before attempting to seek
---
libavformat/mov.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 9da8eab..0f9836c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2763,8 +2763,8 @@ static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st)
if (!sample || (!s->pb->seekable && current_sample->pos < sample->pos) ||
(s->pb->seekable &&
((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb &&
- ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) ||
- (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))))) {
+ ((FFABS(best_dts - dts) <= 4*AV_TIME_BASE && current_sample->pos < sample->pos) ||
+ (FFABS(best_dts - dts) > 4*AV_TIME_BASE && dts < best_dts)))))) {
sample = current_sample;
best_dts = dts;
*st = avst;
--
1.7.9.4

View File

@ -1,38 +0,0 @@
From b83c9a2505338cdf021dd499c26686e82bcbc066 Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Fri, 26 Nov 2010 20:56:48 +0000
Subject: [PATCH 15/24] fixed: memleak in mpegts demuxer on some malformed
(??) mpegts files with too large pes packets
at-visions sample file brokenStream.mpg
---
libavformat/mpegts.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index ba2f163..c374cb9 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -664,6 +664,10 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
static void new_pes_packet(PESContext *pes, AVPacket *pkt)
{
+ if(pkt->data) {
+ av_log(pes->stream, AV_LOG_ERROR, "ignoring previously allocated packet on stream %d\n", pkt->stream_index);
+ av_free_packet(pkt);
+ }
av_init_packet(pkt);
pkt->destruct = av_destruct_packet;
@@ -2117,6 +2121,8 @@ static int mpegts_read_packet(AVFormatContext *s,
int ret, i;
ts->pkt = pkt;
+ ts->pkt->data = NULL;
+
ret = handle_packets(ts, 0);
if (ret < 0) {
/* flush pes data left */
--
1.7.9.4

View File

@ -1,37 +0,0 @@
From c240357f903f20ba51001fb90aa2de415d5be825 Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Mon, 28 Jun 2010 21:26:54 +0000
Subject: [PATCH 16/24] Speed up mpegts av_find_stream_info
---
libavformat/mpegts.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index c374cb9..6da6db5 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -825,7 +825,7 @@ static int mpegts_push_data(MpegTSFilter *filter,
goto skip;
/* stream not present in PMT */
- if (!pes->st) {
+ if (ts->auto_guess && !pes->st) {
pes->st = avformat_new_stream(ts->stream, NULL);
if (!pes->st)
return AVERROR(ENOMEM);
@@ -2013,7 +2013,10 @@ static int mpegts_read_header(AVFormatContext *s,
av_dlog(ts->stream, "tuning done\n");
- s->ctx_flags |= AVFMTCTX_NOHEADER;
+ /* only flag NOHEADER if we are in file mode,
+ in streaming mode scanning may take too long for users */
+ if (!url_is_streamed(pb))
+ s->ctx_flags |= AVFMTCTX_NOHEADER;
} else {
AVStream *st;
int pcr_pid, pid, nb_packets, nb_pcrs, ret, pcr_l;
--
1.7.9.4

View File

@ -1,43 +0,0 @@
From 954d92f3fc2c5bd45fc1b4d347f2d9295d269574 Mon Sep 17 00:00:00 2001
From: Anssi Hannula <anssi.hannula@iki.fi>
Date: Wed, 23 Feb 2011 19:24:07 +0200
Subject: [PATCH 17/24] allow customizing shared library soname (name with
major)
This is a hack.
---
configure | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/configure b/configure
index 6255f57..5e11b2d 100755
--- a/configure
+++ b/configure
@@ -238,6 +238,7 @@ Advanced options (experts only):
--arch=ARCH select architecture [$arch]
--cpu=CPU select the minimum required CPU (affects
instruction selection, may crash on older CPUs)
+ --custom-libname-with-major=NAME custom library name with major [$SLIBNAME_WITH_MAJOR]
--disable-asm disable all assembler optimizations
--disable-altivec disable AltiVec optimizations
--disable-amd3dnow disable 3DNow! optimizations
@@ -1298,6 +1299,7 @@ CMDLINE_SET="
cpu
cross_prefix
cxx
+ custom_libname_with_major
dep_cc
extra_version
host_cc
@@ -2778,6 +2780,8 @@ EOF
exit 1;
fi
+test -n "$custom_libname_with_major" && SLIBNAME_WITH_MAJOR="$custom_libname_with_major"
+
die_license_disabled() {
enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
}
--
1.7.9.4

View File

@ -1,75 +0,0 @@
From 40f4c15370f7027dc5422edcb10e8a3b7e58e83d Mon Sep 17 00:00:00 2001
From: CrystalP <CrystalP@xbmc.org>
Date: Wed, 5 Oct 2011 12:38:30 -0400
Subject: [PATCH 18/24] dxva-mpeg2 Allocate slices array dynamically - fixes
videos with > 175 slices. They used to result in
images with a black bottom.
sample on team ftp samples/PR471/too_many_slices.ts
Inspired by the vaapi code to reallocate the slices array for each new slice.
Could be more efficient if the array could be preserved for all frames and
freed only at the end of the video, but there doesn't seem to be anywhere
appropriate to free the memory at the end.
Alternative is to allocate the proper size straight away for a new frame,
instead of realloc'ing for each slice.
---
libavcodec/dxva2_mpeg2.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c
index 951305d..8ba83b6 100644
--- a/libavcodec/dxva2_mpeg2.c
+++ b/libavcodec/dxva2_mpeg2.c
@@ -22,12 +22,12 @@
#include "dxva2_internal.h"
-#define MAX_SLICES (SLICE_MAX_START_CODE - SLICE_MIN_START_CODE + 1)
struct dxva2_picture_context {
DXVA_PictureParameters pp;
DXVA_QmatrixData qm;
unsigned slice_count;
- DXVA_SliceInfo slice[MAX_SLICES];
+ DXVA_SliceInfo *slice;
+ unsigned int slice_alloc;
const uint8_t *bitstream;
unsigned bitstream_size;
@@ -220,6 +220,8 @@ static int start_frame(AVCodecContext *avctx,
fill_quantization_matrices(avctx, ctx, s, &ctx_pic->qm);
ctx_pic->slice_count = 0;
+ ctx_pic->slice = NULL;
+ ctx_pic->slice_alloc = 0;
ctx_pic->bitstream_size = 0;
ctx_pic->bitstream = NULL;
return 0;
@@ -232,9 +234,14 @@ static int decode_slice(AVCodecContext *avctx,
struct dxva2_picture_context *ctx_pic =
s->current_picture_ptr->f.hwaccel_picture_private;
unsigned position;
+ DXVA_SliceInfo* slice;
- if (ctx_pic->slice_count >= MAX_SLICES)
+ slice = av_fast_realloc(ctx_pic->slice,
+ &ctx_pic->slice_alloc,
+ (ctx_pic->slice_count + 1) * sizeof(DXVA_SliceInfo));
+ if (!slice)
return -1;
+ ctx_pic->slice = slice;
if (!ctx_pic->bitstream)
ctx_pic->bitstream = buffer;
@@ -258,6 +265,7 @@ static int end_frame(AVCodecContext *avctx)
&ctx_pic->pp, sizeof(ctx_pic->pp),
&ctx_pic->qm, sizeof(ctx_pic->qm),
commit_bitstream_and_slice_buffer);
+ av_freep(ctx_pic->slice);
}
AVHWAccel ff_mpeg2_dxva2_hwaccel = {
--
1.7.9.4

View File

@ -1,74 +0,0 @@
From 681f74b224e16a4df7f8c4e31a9be56975d57e10 Mon Sep 17 00:00:00 2001
From: CrystalP <CrystalP@xbmc.org>
Date: Mon, 10 Oct 2011 19:42:50 -0400
Subject: [PATCH 19/24] dxva-mpeg2 speed up slice allocation
The number of slices is not very likely to change from frame to frame, so
at the beginning of a new frame, allocate memory for the amount of slices of
the previous frame. Saves a lot of reallocation, for some TV capture samples
there are over 200 slices.
There wasn't anywhere really appropriate to store last_slice_count (needs to
live from first frame to last frame), so this is likely to cause discussion to
merge upstream.
Adding members to dxva_context breaks ABI, which we don't care too much about
since on Windows we don't support external ffmpeg.
dxva mpeg2 code also has access to MpegEncContext, but adding there would
likely break ABI as well.
---
libavcodec/dxva2.h | 1 +
libavcodec/dxva2_mpeg2.c | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/libavcodec/dxva2.h b/libavcodec/dxva2.h
index fc99560..16a6994 100644
--- a/libavcodec/dxva2.h
+++ b/libavcodec/dxva2.h
@@ -66,6 +66,7 @@ struct dxva_context {
* Private to the FFmpeg AVHWAccel implementation
*/
unsigned report_id;
+ unsigned last_slice_count;
};
#endif /* AVCODEC_DXVA_H */
diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c
index 8ba83b6..90507f9 100644
--- a/libavcodec/dxva2_mpeg2.c
+++ b/libavcodec/dxva2_mpeg2.c
@@ -224,6 +224,16 @@ static int start_frame(AVCodecContext *avctx,
ctx_pic->slice_alloc = 0;
ctx_pic->bitstream_size = 0;
ctx_pic->bitstream = NULL;
+
+ if (ctx->last_slice_count > 0)
+ {
+ ctx_pic->slice = av_fast_realloc(NULL,
+ &ctx_pic->slice_alloc,
+ ctx->last_slice_count * sizeof(DXVA_SliceInfo));
+ if (!ctx_pic->slice)
+ return -1;
+ }
+
return 0;
}
@@ -258,6 +268,7 @@ static int end_frame(AVCodecContext *avctx)
struct MpegEncContext *s = avctx->priv_data;
struct dxva2_picture_context *ctx_pic =
s->current_picture_ptr->f.hwaccel_picture_private;
+ struct dxva_context *ctx = avctx->hwaccel_context;
if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
return -1;
@@ -266,6 +277,7 @@ static int end_frame(AVCodecContext *avctx)
&ctx_pic->qm, sizeof(ctx_pic->qm),
commit_bitstream_and_slice_buffer);
av_freep(ctx_pic->slice);
+ ctx->last_slice_count = ctx_pic->slice_count;
}
AVHWAccel ff_mpeg2_dxva2_hwaccel = {
--
1.7.9.4

View File

@ -1,49 +0,0 @@
From 1c0fcc2cfe27197368e0490afe34dd51a831995f Mon Sep 17 00:00:00 2001
From: CrystalP <CrystalP@xbmc.org>
Date: Wed, 5 Oct 2011 12:53:38 -0400
Subject: [PATCH 20/24] dxva-vc1 Take BI into account for forward and backward
pictures
See ticket #11643, sample on team ftp, samples/11643/vc-1 test.wmv
---
libavcodec/dxva2_vc1.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c
index 0ae9685..23507d3 100644
--- a/libavcodec/dxva2_vc1.c
+++ b/libavcodec/dxva2_vc1.c
@@ -38,15 +38,17 @@ static void fill_picture_parameters(AVCodecContext *avctx,
{
const MpegEncContext *s = &v->s;
const Picture *current_picture = s->current_picture_ptr;
+ BYTE bPicIntra = s->pict_type == AV_PICTURE_TYPE_I || v->bi_type == 1;
+ BYTE bPicBackwardPrediction = s->pict_type == AV_PICTURE_TYPE_B && v->bi_type == 0;
memset(pp, 0, sizeof(*pp));
pp->wDecodedPictureIndex =
pp->wDeblockedPictureIndex = ff_dxva2_get_surface_index(ctx, current_picture);
- if (s->pict_type != AV_PICTURE_TYPE_I)
+ if (!bPicIntra)
pp->wForwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->last_picture);
else
pp->wForwardRefPictureIndex = 0xffff;
- if (s->pict_type == AV_PICTURE_TYPE_B)
+ if (bPicBackwardPrediction)
pp->wBackwardRefPictureIndex = ff_dxva2_get_surface_index(ctx, &s->next_picture);
else
pp->wBackwardRefPictureIndex = 0xffff;
@@ -69,8 +71,8 @@ static void fill_picture_parameters(AVCodecContext *avctx,
if (s->picture_structure & PICT_BOTTOM_FIELD)
pp->bPicStructure |= 0x02;
pp->bSecondField = v->interlace && v->fcm != ILACE_FIELD && !s->first_field;
- pp->bPicIntra = s->pict_type == AV_PICTURE_TYPE_I;
- pp->bPicBackwardPrediction = s->pict_type == AV_PICTURE_TYPE_B;
+ pp->bPicIntra = bPicIntra;
+ pp->bPicBackwardPrediction = bPicBackwardPrediction;
pp->bBidirectionalAveragingMode = (1 << 7) |
((ctx->cfg->ConfigIntraResidUnsigned != 0) << 6) |
((ctx->cfg->ConfigResidDiffAccelerator != 0) << 5) |
--
1.7.9.4

View File

@ -1,29 +0,0 @@
From 6ba7fd3e2acf39e8c276e7db901c54dba0fd8307 Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Sat, 22 Oct 2011 21:59:22 +0200
Subject: [PATCH 21/24] dxva-vc1 Pass overlapping transforms hint
see ticket #11643
---
libavcodec/dxva2_vc1.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c
index 23507d3..9d550dd 100644
--- a/libavcodec/dxva2_vc1.c
+++ b/libavcodec/dxva2_vc1.c
@@ -103,7 +103,10 @@ static void fill_picture_parameters(AVCodecContext *avctx,
(v->rangered << 3) |
(s->max_b_frames );
pp->bPicExtrapolation = (!v->interlace || v->fcm == PROGRESSIVE) ? 1 : 2;
- pp->bPicDeblocked = ((v->profile != PROFILE_ADVANCED && v->rangeredfrm) << 5) |
+ pp->bPicDeblocked = ((v->overlap == 1 &&
+ pp->bPicBackwardPrediction == 0 &&
+ ctx->cfg->ConfigResidDiffHost == 0) << 6) |
+ ((v->profile != PROFILE_ADVANCED && v->rangeredfrm) << 5) |
(s->loop_filter << 1);
pp->bPicDeblockConfined = (v->postprocflag << 7) |
(v->broadcast << 6) |
--
1.7.9.4

View File

@ -1,75 +0,0 @@
From 3b6417ff1e86c2aa72fc5360f67be2db8b83b80d Mon Sep 17 00:00:00 2001
From: CrystalP <CrystalP@xbmc.org>
Date: Wed, 5 Oct 2011 13:13:25 -0400
Subject: [PATCH 22/24] dxva-h264 Fix dxva playback of streams that don't
start with an I-Frame.
GPUs with ATI UVDa and UVD+ have trouble when decoding doesn't start on an
I-Frame, and they don't recover on later I-Frames.
The variable to track the first I-Frame is in H264Context so that it can be
reset by code in h264 when initializing the context or flushing.
credits isidrogar, see ticket #11772.
sample on team ftp, samples/11772/CSI_ New York - TV3 - 2008-09-16_1.ts
---
libavcodec/dxva2_h264.c | 8 ++++++++
libavcodec/h264.c | 2 ++
libavcodec/h264.h | 2 ++
3 files changed, 12 insertions(+)
diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index af91e02..b7e0251 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -432,6 +432,14 @@ static int end_frame(AVCodecContext *avctx)
if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
return -1;
+
+ // Wait for an I-frame before start decoding. Workaround for ATI UVD and UVD+ GPUs
+ if (!h->got_first_iframe) {
+ if (!(ctx_pic->pp.wBitFields & (1 << 15)))
+ return -1;
+ h->got_first_iframe = 1;
+ }
+
return ff_dxva2_common_end_frame(avctx, s,
&ctx_pic->pp, sizeof(ctx_pic->pp),
&ctx_pic->qm, sizeof(ctx_pic->qm),
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index d010b55..98c7a5d 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -2372,6 +2372,7 @@ static void flush_dpb(AVCodecContext *avctx){
h->delayed_pic[i]->f.reference = 0;
h->delayed_pic[i]= NULL;
}
+ h->got_first_iframe = 0;
h->outputed_poc=h->next_outputed_poc= INT_MIN;
h->prev_interlaced_frame = 1;
idr(h);
@@ -2819,6 +2820,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
}
s->first_field = 0;
h->prev_interlaced_frame = 1;
+ h->got_first_iframe = 0;
init_scan_tables(h);
if (ff_h264_alloc_tables(h) < 0) {
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index d0dfca3..f4df997 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -584,6 +584,8 @@ typedef struct H264Context{
int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag
int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag
+ int got_first_iframe;
+
// Timestamp stuff
int sei_buffering_period_present; ///< Buffering period SEI flag
int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
--
1.7.9.4

View File

@ -1,26 +0,0 @@
From 0b24d2cd7338ddba22926a7725dc751cc801ac78 Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Sat, 22 Oct 2011 22:01:31 +0200
Subject: [PATCH 23/24] Changed format string - %td not supported by our MingW
environment.
---
libavcodec/h264.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 98c7a5d..c4785db 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -3629,7 +3629,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
return 0;
}
if( ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 2) {
- av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d, bytestream (%td)\n", s->mb_x, s->mb_y, h->cabac.bytestream_end - h->cabac.bytestream);
+ av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d, bytestream (%d)\n", s->mb_x, s->mb_y, h->cabac.bytestream_end - h->cabac.bytestream);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR&part_mask);
return -1;
}
--
1.7.9.4

View File

@ -1,48 +0,0 @@
From 399301fd74ed748d24d7ee2806f50e8ad57aeea8 Mon Sep 17 00:00:00 2001
From: elupus <elupus@xbmc.org>
Date: Tue, 1 Nov 2011 20:18:35 +0100
Subject: [PATCH 24/24] add public version of ff_read_frame_flush
We need this since we sometimes seek on the
input stream behind ffmpeg's back. After this
all data need to be flushed completely.
---
libavformat/avformat.h | 5 +++++
libavformat/utils.c | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 1e8a629..c76ac71 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1631,6 +1631,11 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt);
int av_read_frame(AVFormatContext *s, AVPacket *pkt);
/**
+ * Clear out any buffered data in context
+ */
+void av_read_frame_flush(AVFormatContext *s);
+
+/**
* Seek to the keyframe at timestamp.
* 'timestamp' in 'stream_index'.
* @param stream_index If stream_index is (-1), a default
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 25fe38e..4729a40 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1463,6 +1463,11 @@ void ff_read_frame_flush(AVFormatContext *s)
}
}
+void av_read_frame_flush(AVFormatContext *s)
+{
+ ff_read_frame_flush(s);
+}
+
#if FF_API_SEEK_PUBLIC
void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp)
{
--
1.7.9.4

View File

@ -1,65 +0,0 @@
From 6261cbcd71e5cd192623434fa698e9f1e701f365 Mon Sep 17 00:00:00 2001
From: Paul Kendall <paul@kcbbs.gen.nz>
Date: Sun, 29 Jan 2012 14:50:19 +0100
Subject: [PATCH 1/1] Fix dvb subtitle decoding when display segment is
missing.
closes ticket #8504
---
libavcodec/dvbsubdec.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index e2a804a..503223f 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -1451,6 +1451,7 @@ static int dvbsub_decode(AVCodecContext *avctx,
int segment_type;
int page_id;
int segment_length;
+ int got_segment = 0;
int i;
av_dlog(avctx, "DVB sub packet:\n");
@@ -1490,21 +1491,26 @@ static int dvbsub_decode(AVCodecContext *avctx,
switch (segment_type) {
case DVBSUB_PAGE_SEGMENT:
dvbsub_parse_page_segment(avctx, p, segment_length);
+ got_segment |= 1;
break;
case DVBSUB_REGION_SEGMENT:
dvbsub_parse_region_segment(avctx, p, segment_length);
+ got_segment |= 2;
break;
case DVBSUB_CLUT_SEGMENT:
dvbsub_parse_clut_segment(avctx, p, segment_length);
+ got_segment |= 4;
break;
case DVBSUB_OBJECT_SEGMENT:
dvbsub_parse_object_segment(avctx, p, segment_length);
+ got_segment |= 8;
break;
case DVBSUB_DISPLAYDEFINITION_SEGMENT:
dvbsub_parse_display_definition_segment(avctx, p, segment_length);
break;
case DVBSUB_DISPLAY_SEGMENT:
*data_size = dvbsub_display_end_segment(avctx, p, segment_length, sub);
+ got_segment |= 16;
break;
default:
av_dlog(avctx, "Subtitling segment type 0x%x, page id %d, length %d\n",
@@ -1516,6 +1522,11 @@ static int dvbsub_decode(AVCodecContext *avctx,
p += segment_length;
}
+ // Some streams do not send a display segment but if we have all the other
+ // segments then we need no further data.
+ if (got_segment == 15 && sub)
+ *data_size = dvbsub_display_end_segment(avctx, p, 0, sub);
+
return p - buf;
}
--
1.7.9.4

View File

@ -1,51 +0,0 @@
From d659958d58dfec08f4666a8add325c8154a662de Mon Sep 17 00:00:00 2001
From: CrystalP <CrystalP@xbmc.org>
Date: Fri, 11 Nov 2011 19:10:54 -0500
Subject: [PATCH 1/1] Handle return value of BeginFrame better.
The nVidia cards sometimes return E_PENDING and need time before they can start
decoding a new frame.
Helps nVidia cards with blocky pictures/pixellation artifacts after skip or
when CPU is busy.
---
libavcodec/dxva2.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index b6f8aea..3a10f69 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -21,6 +21,9 @@
*/
#include "dxva2_internal.h"
+#include <unistd.h>
+
+#define MAX_RETRY_ON_PENDING 50
void *ff_dxva2_get_surface(const Picture *picture)
{
@@ -88,10 +91,17 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, MpegEncContext *s,
DXVA2_DecodeBufferDesc buffer[4];
DXVA2_DecodeExecuteParams exec;
int result;
+ HRESULT hr;
+ int tries = 0;
- if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder,
+ while ((hr=IDirectXVideoDecoder_BeginFrame(ctx->decoder,
ff_dxva2_get_surface(s->current_picture_ptr),
- NULL))) {
+ NULL)) == E_PENDING
+ && tries < MAX_RETRY_ON_PENDING) {
+ usleep(1000);
+ tries++;
+ }
+ if (FAILED(hr)) {
av_log(avctx, AV_LOG_ERROR, "Failed to begin frame\n");
return -1;
}
--
1.7.9.4

View File

@ -1,43 +0,0 @@
From 864acb01cc73762918794ddecf0fc2f7b6cf8529 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Brochet?= <blinkseb@xbmc.org>
Date: Sun, 15 Apr 2012 22:43:46 +0200
Subject: [PATCH 1/3] added: support for OTF fonts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Sébastien Brochet <blinkseb@xbmc.org>
---
libavcodec/avcodec.h | 1 +
libavformat/matroska.c | 1 +
2 files changed, 2 insertions(+), 0 deletion(-)
diff --git a/lib/ffmpeg/libavcodec/avcodec.h b/lib/ffmpeg/libavcodec/avcodec.h
index 0b756d0..6996c92 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -435,6 +435,7 @@ enum CodecID {
CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'),
CODEC_ID_XBIN = MKBETAG('X','B','I','N'),
CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'),
+ CODEC_ID_OTF = MKBETAG( 0 ,'O','T','F'),
CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
diff --git a/lib/ffmpeg/libavformat/matroska.c b/lib/ffmpeg/libavformat/matroska.c
index 52481d7..2f5b617 100644
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -90,6 +90,7 @@ const CodecMime ff_mkv_mime_tags[] = {
{"image/tiff" , CODEC_ID_TIFF},
{"application/x-truetype-font", CODEC_ID_TTF},
{"application/x-font" , CODEC_ID_TTF},
+ {"application/vnd.ms-opentype", CODEC_ID_OTF},
{"" , CODEC_ID_NONE}
};
index 17cbd48..4524141 100644
--
1.7.10.msysgit.1

View File

@ -1,35 +0,0 @@
From 90a3ab0d766e3a026a37f7290f59abda30c4de32 Mon Sep 17 00:00:00 2001
From: elupus <elupus@xbmc.org>
Date: Tue, 17 Apr 2012 01:13:15 +0200
Subject: [PATCH] fixed: dvd still frames ended up in internal lavf buffer
This is very hackish, but it's the old solution we had for dvd
still frames. The problem is that the demuxer asks for probing
of the codec in the mpeg stream. This causes lavf to read the
whole menu structure into internal buffers. After which, it
won't read from input stream anymore and no events triggers.
The only proper fix to avoid this is to allow this situation
in our navigator. This needs further work so that we can
process HOP/ACTIVATION events in libdvdnav without advancing
stream.
---
libavformat/utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 1bf81a5..051dcc0 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -833,7 +833,7 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt)
if(end || av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)){
int score= set_codec_from_probe_data(s, st, pd);
- if( (st->codec->codec_id != CODEC_ID_NONE && score > AVPROBE_SCORE_MAX/4)
+ if( (st->codec->codec_id != CODEC_ID_NONE && score > AVPROBE_SCORE_MAX/4-1)
|| end){
pd->buf_size=0;
av_freep(&pd->buf);
--
1.7.9.4

View File

@ -1,14 +0,0 @@
diff --git a/configure b/configure
index 5e11b2d..c06005b 100755
--- a/configure
+++ b/configure
@@ -2635,7 +2635,7 @@ case $target_os in
;;
darwin)
enable malloc_aligned
- gas="gas-preprocessor.pl $cc"
+ #gas="gas-preprocessor.pl $cc"
enabled ppc && add_asflags -force_cpusubtype_ALL
SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress

View File

@ -1,207 +0,0 @@
From 2ac4f22e8cea4489431cf879edba31124f19c3ba Mon Sep 17 00:00:00 2001
From: Memphiz <memphis@machzwo.de>
Date: Fri, 29 Jun 2012 19:41:48 +0200
Subject: [PATCH] [ffmpeg] - ARM: generate position independent code to access
data symbols - this finally fixes our ATV2 builds. I send
more then a really big THX to M.Rullgard from libav for
making this happen.
---
lib/ffmpeg/libavcodec/arm/ac3dsp_armv6.S | 4 +-
lib/ffmpeg/libavcodec/arm/asm.S | 73 +++++++++++++++++++++++++++-
lib/ffmpeg/libavcodec/arm/fft_fixed_neon.S | 2 +-
lib/ffmpeg/libavcodec/arm/fft_neon.S | 4 +-
lib/ffmpeg/libavcodec/arm/vp3dsp_neon.S | 3 +-
lib/ffmpeg/libavcodec/arm/vp8_armv6.S | 4 +-
6 files changed, 80 insertions(+), 10 deletions(-)
diff --git a/libavcodec/arm/ac3dsp_armv6.S b/libavcodec/arm/ac3dsp_armv6.S
index b6aee86..97099d6 100644
--- a/libavcodec/arm/ac3dsp_armv6.S
+++ b/libavcodec/arm/ac3dsp_armv6.S
@@ -26,8 +26,8 @@ function ff_ac3_bit_alloc_calc_bap_armv6, export=1
beq 4f
push {r4-r11,lr}
add r5, sp, #40
- movrel r4, X(ff_ac3_bin_to_band_tab)
- movrel lr, X(ff_ac3_band_start_tab)
+ movrelx r4, X(ff_ac3_bin_to_band_tab), r11
+ movrelx lr, X(ff_ac3_band_start_tab)
ldm r5, {r5-r7}
ldrb r4, [r4, r2]
add r1, r1, r2, lsl #1 @ psd + start
diff --git a/libavcodec/arm/asm.S b/libavcodec/arm/asm.S
index e540eac..d34a16d 100644
--- a/libavcodec/arm/asm.S
+++ b/libavcodec/arm/asm.S
@@ -62,7 +62,14 @@ ELF .eabi_attribute 25, \val
.endm
.macro function name, export=0
+ .set .Lpic_idx, 0
+ .set .Lpic_gp, 0
.macro endfunc
+ .if .Lpic_idx
+ .altmacro
+ put_pic %(.Lpic_idx - 1)
+ .noaltmacro
+ .endif
ELF .size \name, . - \name
.endfunc
.purgem endfunc
@@ -99,8 +106,44 @@ ELF .size \name, . - \name
#endif
.endm
+.macro put_pic num
+ put_pic_\num
+.endm
+
+.macro do_def_pic num, val, label
+ .macro put_pic_\num
+ .if \num
+ .altmacro
+ put_pic %(\num - 1)
+ .noaltmacro
+ .endif
+\label: .word \val
+ .purgem put_pic_\num
+ .endm
+.endm
+
+.macro def_pic val, label
+ .altmacro
+ do_def_pic %.Lpic_idx, \val, \label
+ .noaltmacro
+ .set .Lpic_idx, .Lpic_idx + 1
+.endm
+
+.macro ldpic rd, val, indir=0
+ ldr \rd, .Lpicoff\@
+.Lpic\@:
+ .if \indir
+ ldr \rd, [pc, \rd]
+ .else
+ add \rd, pc, \rd
+ .endif
+ def_pic \val - (.Lpic\@ + (8 >> CONFIG_THUMB)), .Lpicoff\@
+.endm
+
.macro movrel rd, val
-#if HAVE_ARMV6T2 && !CONFIG_PIC && !defined(__APPLE__)
+#if CONFIG_PIC
+ ldpic \rd, \val
+#elif HAVE_ARMV6T2 && !defined(__APPLE__)
movw \rd, #:lower16:\val
movt \rd, #:upper16:\val
#else
@@ -108,6 +151,34 @@ ELF .size \name, . - \name
#endif
.endm
+.macro movrelx rd, val, gp
+#if CONFIG_PIC && defined(__ELF__)
+ .ifnb \gp
+ .if .Lpic_gp
+ .unreq gp
+ .endif
+ gp .req \gp
+ ldpic gp, _GLOBAL_OFFSET_TABLE_
+ .elseif !.Lpic_gp
+ gp .req r12
+ ldpic gp, _GLOBAL_OFFSET_TABLE_
+ .endif
+ .set .Lpic_gp, 1
+ ldr \rd, .Lpicoff\@
+ ldr \rd, [gp, \rd]
+ def_pic \val(GOT), .Lpicoff\@
+#elif CONFIG_PIC && defined(__APPLE__)
+ ldpic \rd, .Lpic\@, indir=1
+ .non_lazy_symbol_pointer
+.Lpic\@:
+ .indirect_symbol \val
+ .word 0
+ .text
+#else
+ movrel \rd, \val
+#endif
+.endm
+
.macro ldr_pre rt, rn, rm:vararg
A ldr \rt, [\rn, \rm]!
T add \rn, \rn, \rm
diff --git a/libavcodec/arm/fft_fixed_neon.S b/libavcodec/arm/fft_fixed_neon.S
index 0316b80..d6b7dac 100644
--- a/libavcodec/arm/fft_fixed_neon.S
+++ b/libavcodec/arm/fft_fixed_neon.S
@@ -214,7 +214,7 @@ function fft\n\()_neon
bl fft\n4\()_neon
mov r0, r4
pop {r4, lr}
- movrel r1, X(ff_cos_\n\()_fixed)
+ movrelx r1, X(ff_cos_\n\()_fixed)
mov r2, #\n4/2
b fft_pass_neon
endfunc
diff --git a/libavcodec/arm/fft_neon.S b/libavcodec/arm/fft_neon.S
index ef8e4d4..d36927b 100644
--- a/libavcodec/arm/fft_neon.S
+++ b/libavcodec/arm/fft_neon.S
@@ -143,7 +143,7 @@ function fft16_neon
vswp d29, d30 @ q14{r12,i12,i14,r15} q15{r13,i13,i15,r14}
vadd.f32 q0, q12, q13 @ {t1,t2,t5,t6}
vadd.f32 q1, q14, q15 @ {t1a,t2a,t5a,t6a}
- movrel r2, X(ff_cos_16)
+ movrelx r2, X(ff_cos_16)
vsub.f32 q13, q12, q13 @ {t3,t4,t7,t8}
vrev64.32 d1, d1
vsub.f32 q15, q14, q15 @ {t3a,t4a,t7a,t8a}
@@ -290,7 +290,7 @@ function fft\n\()_neon
bl fft\n4\()_neon
mov r0, r4
pop {r4, lr}
- movrel r1, X(ff_cos_\n)
+ movrelx r1, X(ff_cos_\n)
mov r2, #\n4/2
b fft_pass_neon
endfunc
diff --git a/libavcodec/arm/vp3dsp_neon.S b/libavcodec/arm/vp3dsp_neon.S
index ae3e402..90d9f80 100644
--- a/libavcodec/arm/vp3dsp_neon.S
+++ b/libavcodec/arm/vp3dsp_neon.S
@@ -116,9 +116,8 @@ function vp3_idct_start_neon
vadd.s16 q1, q8, q12
vsub.s16 q8, q8, q12
vld1.64 {d28-d31}, [r2,:128]!
-endfunc
-function vp3_idct_core_neon
+vp3_idct_core_neon:
vmull.s16 q2, d18, xC1S7 // (ip[1] * C1) << 16
vmull.s16 q3, d19, xC1S7
vmull.s16 q4, d2, xC4S4 // ((ip[0] + ip[4]) * C4) << 16
diff --git a/libavcodec/arm/vp8_armv6.S b/libavcodec/arm/vp8_armv6.S
index 8a3beb9..adb49f7 100644
--- a/libavcodec/arm/vp8_armv6.S
+++ b/libavcodec/arm/vp8_armv6.S
@@ -65,7 +65,7 @@ T orrcs \cw, \cw, \t1
function ff_decode_block_coeffs_armv6, export=1
push {r0,r1,r4-r11,lr}
- movrel lr, X(ff_vp56_norm_shift)
+ movrelx lr, X(ff_vp56_norm_shift)
ldrd r4, r5, [sp, #44] @ token_prob, qmul
cmp r3, #0
ldr r11, [r5]
@@ -206,7 +206,7 @@ A orrcs r8, r8, r10, lsl r6
mov r9, #8
it ge
addge r12, r12, #1
- movrel r4, X(ff_vp8_dct_cat_prob)
+ movrelx r4, X(ff_vp8_dct_cat_prob), r1
lsl r9, r9, r12
ldr r4, [r4, r12, lsl #2]
add r12, r9, #3
--
1.7.9.4

View File

@ -1,56 +0,0 @@
#The clang integrated assembler does not support pre-UAL syntax,
#while gcc requires pre-UAL syntax for ARM code. A patch[1] for
#clang to support the old syntax as well has been ignored since
#January.
#
#This patch chooses the syntax appropriate for each compiler,
#allowing both to build the code. Notably, this change allows
#building for iphone with the latest Apple Xcode update.
#
#[1] http://llvm.org/bugs/show_bug.cgi?id=11855
#
#Signed-off-by: Mans Rullgard <mans at mansr.com>
diff --git a/libavcodec/arm/vp56_arith.h b/libavcodec/arm/vp56_arith.h
index ef30ffe..d1a8837 100644
--- a/libavcodec/arm/vp56_arith.h
+++ b/libavcodec/arm/vp56_arith.h
@@ -29,6 +29,14 @@
# define T(x)
#endif
+#if CONFIG_THUMB || defined __clang__
+# define L(x)
+# define U(x) x
+#else
+# define L(x) x
+# define U(x)
+#endif
+
#if HAVE_ARMV6 && HAVE_INLINE_ASM
#define vp56_rac_get_prob vp56_rac_get_prob_armv6
@@ -42,8 +50,8 @@ static inline int vp56_rac_get_prob_armv6(VP56RangeCoder *c, int pr)
__asm__ ("adds %3, %3, %0 \n"
"itt cs \n"
"cmpcs %7, %4 \n"
- A("ldrcsh %2, [%4], #2 \n")
- T("ldrhcs %2, [%4], #2 \n")
+ L("ldrcsh %2, [%4], #2 \n")
+ U("ldrhcs %2, [%4], #2 \n")
"rsb %0, %6, #256 \n"
"smlabb %0, %5, %6, %0 \n"
T("itttt cs \n")
@@ -80,8 +88,8 @@ static inline int vp56_rac_get_prob_branchy_armv6(VP56RangeCoder *c, int pr)
__asm__ ("adds %3, %3, %0 \n"
"itt cs \n"
"cmpcs %7, %4 \n"
- A("ldrcsh %2, [%4], #2 \n")
- T("ldrhcs %2, [%4], #2 \n")
+ L("ldrcsh %2, [%4], #2 \n")
+ U("ldrhcs %2, [%4], #2 \n")
"rsb %0, %6, #256 \n"
"smlabb %0, %5, %6, %0 \n"
T("itttt cs \n")
--
1.7.11.1

View File

@ -1,64 +0,0 @@
diff --git a/lib/ffmpeg/libavcodec/pgssubdec.c b/lib/ffmpeg/libavcodec/pgssubdec.c
index 2785d25..02e650a 100644
--- a/libavcodec/pgssubdec.c
+++ b/libavcodec/pgssubdec.c
@@ -64,6 +64,7 @@ typedef struct PGSSubContext {
PGSSubPresentation presentation;
uint32_t clut[256];
PGSSubPicture pictures[UINT16_MAX];
+ int64_t pts;
} PGSSubContext;
static av_cold int init_decoder(AVCodecContext *avctx)
@@ -377,6 +378,7 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
{
AVSubtitle *sub = data;
PGSSubContext *ctx = avctx->priv_data;
+ int64_t pts;
uint16_t rect;
@@ -386,7 +388,10 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
* not been cleared by a subsequent empty display command.
*/
+ pts = ctx->pts != AV_NOPTS_VALUE ? ctx->pts : sub->pts;
memset(sub, 0, sizeof(*sub));
+ sub->pts = pts;
+ ctx->pts = AV_NOPTS_VALUE;
// Blank if last object_count was 0.
if (!ctx->presentation.object_count)
@@ -431,8 +436,10 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
static int decode(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
+ PGSSubContext *ctx = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
+ AVSubtitle *sub = data;
const uint8_t *buf_end;
uint8_t segment_type;
@@ -477,6 +484,7 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size,
break;
case PRESENTATION_SEGMENT:
parse_presentation_segment(avctx, buf, segment_length);
+ ctx->pts = sub->pts;
break;
case WINDOW_SEGMENT:
/*
diff --git a/lib/ffmpeg/libavcodec/utils.c b/lib/ffmpeg/libavcodec/utils.c
index 99bf27c..c1cde2c 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1396,6 +1396,9 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
avctx->pkt = avpkt;
*got_sub_ptr = 0;
avcodec_get_subtitle_defaults(sub);
+ if (avctx->time_base.den && avpkt->pts != AV_NOPTS_VALUE)
+ sub->pts = av_rescale_q(avpkt->pts,
+ avctx->time_base, AV_TIME_BASE_Q);
ret = avctx->codec->decode(avctx, sub, got_sub_ptr, avpkt);
if (*got_sub_ptr)
avctx->frame_number++;

View File

@ -1,62 +0,0 @@
From cd2f98f365dfd83f0debac030413e57a73c7ecd5 Mon Sep 17 00:00:00 2001
From: Mans Rullgard <mans@mansr.com>
Date: Wed, 1 Feb 2012 22:25:10 +0000
Subject: [PATCH] ARM: ac3: fix ac3_bit_alloc_calc_bap_armv6
This function was broken when the start bin was not at the start
of a band.
Signed-off-by: Mans Rullgard <mans@mansr.com>
---
libavcodec/arm/ac3dsp_armv6.S | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/libavcodec/arm/ac3dsp_armv6.S b/libavcodec/arm/ac3dsp_armv6.S
index b6aee86..df8bfba 100644
--- a/libavcodec/arm/ac3dsp_armv6.S
+++ b/libavcodec/arm/ac3dsp_armv6.S
@@ -34,24 +34,23 @@ function ff_ac3_bit_alloc_calc_bap_armv6, export=1
add r0, r0, r4, lsl #1 @ mask + band
add r4, lr, r4
add r7, r7, r2 @ bap + start
- ldrb r10, [r4], #1
1:
ldrsh r9, [r0], #2 @ mask[band]
mov r8, #0xff0
sub r9, r9, r12 @ - snr_offset
- mov r11, r10
- ldrb r10, [r4], #1 @ band_start_tab[band++]
+ ldrb r10, [r4, #1]! @ band_start_tab[++band]
subs r9, r9, r5 @ - floor
it lt
movlt r9, #0
cmp r10, r3 @ - end
and r9, r9, r8, lsl #1 @ & 0x1fe0
ite gt
- subgt r8, r3, r11
- suble r8, r10, r11
+ subgt r8, r3, r2
+ suble r8, r10, r2
+ mov r2, r10
add r9, r9, r5 @ + floor => m
tst r8, #1
- add r2, r7, r8
+ add r11, r7, r8
bne 3f
b 5f
2:
@@ -65,9 +64,9 @@ function ff_ac3_bit_alloc_calc_bap_armv6, export=1
ldrb lr, [r6, lr]
strb r8, [r7], #1 @ bap[bin]
strb lr, [r7], #1
-5: cmp r7, r2
+5: cmp r7, r11
blo 2b
- cmp r3, r11
+ cmp r3, r10
bgt 1b
pop {r4-r11,pc}
3:
--
1.7.10.4

View File

@ -1,257 +0,0 @@
From 1846ddf0a7870e6862905121d4e9da1c283d6ff6 Mon Sep 17 00:00:00 2001
From: Mans Rullgard <mans@mansr.com>
Date: Fri, 19 Oct 2012 13:39:11 +0100
Subject: [PATCH] ARM: fix overreads in neon h264 chroma mc
The loops were reading ahead one line, which could end up outside the
buffer for reference blocks at the edge of the picture. Removing
this readahead has no measurable performance impact.
Signed-off-by: Mans Rullgard <mans@mansr.com>
---
libavcodec/arm/h264cmc_neon.S | 86 +++++++++++++---------------------------
1 files changed, 28 insertions(+), 58 deletions(-)
diff --git a/libavcodec/arm/h264cmc_neon.S b/libavcodec/arm/h264cmc_neon.S
index c7e5460..3427e36 100644
--- a/libavcodec/arm/h264cmc_neon.S
+++ b/libavcodec/arm/h264cmc_neon.S
@@ -51,24 +51,20 @@ T cmp r7, #0
beq 2f
- add r5, r1, r2
-
vdup.8 d0, r4
- lsl r4, r2, #1
vdup.8 d1, r12
- vld1.8 {d4, d5}, [r1], r4
+ vld1.8 {d4, d5}, [r1], r2
vdup.8 d2, r6
- vld1.8 {d6, d7}, [r5], r4
vdup.8 d3, r7
-
vext.8 d5, d4, d5, #1
- vext.8 d7, d6, d7, #1
-1: pld [r5]
+1: vld1.8 {d6, d7}, [r1], r2
vmull.u8 q8, d4, d0
vmlal.u8 q8, d5, d1
- vld1.8 {d4, d5}, [r1], r4
+ vext.8 d7, d6, d7, #1
+ vld1.8 {d4, d5}, [r1], r2
vmlal.u8 q8, d6, d2
+ pld [r1]
vext.8 d5, d4, d5, #1
vmlal.u8 q8, d7, d3
vmull.u8 q9, d6, d0
@@ -76,8 +72,7 @@ T cmp r7, #0
vmlal.u8 q9, d7, d1
vmlal.u8 q9, d4, d2
vmlal.u8 q9, d5, d3
- vld1.8 {d6, d7}, [r5], r4
- pld [r1]
+ pld [r1, r2]
.ifc \codec,h264
vrshrn.u16 d16, q8, #6
vrshrn.u16 d17, q9, #6
@@ -92,7 +87,6 @@ T cmp r7, #0
vld1.8 {d21}, [lr,:64], r2
vrhadd.u8 q8, q8, q10
.endif
- vext.8 d7, d6, d7, #1
vst1.8 {d16}, [r0,:64], r2
vst1.8 {d17}, [r0,:64], r2
bgt 1b
@@ -106,18 +100,15 @@ T cmp r7, #0
beq 4f
- add r5, r1, r2
- lsl r4, r2, #1
- vld1.8 {d4}, [r1], r4
- vld1.8 {d6}, [r5], r4
+ vld1.8 {d4}, [r1], r2
-3: pld [r5]
+3: vld1.8 {d6}, [r1], r2
vmull.u8 q8, d4, d0
vmlal.u8 q8, d6, d1
- vld1.8 {d4}, [r1], r4
+ vld1.8 {d4}, [r1], r2
vmull.u8 q9, d6, d0
vmlal.u8 q9, d4, d1
- vld1.8 {d6}, [r5], r4
+ pld [r1]
.ifc \codec,h264
vrshrn.u16 d16, q8, #6
vrshrn.u16 d17, q9, #6
@@ -127,13 +118,13 @@ T cmp r7, #0
vshrn.u16 d16, q8, #6
vshrn.u16 d17, q9, #6
.endif
+ pld [r1, r2]
.ifc \type,avg
vld1.8 {d20}, [lr,:64], r2
vld1.8 {d21}, [lr,:64], r2
vrhadd.u8 q8, q8, q10
.endif
subs r3, r3, #2
- pld [r1]
vst1.8 {d16}, [r0,:64], r2
vst1.8 {d17}, [r0,:64], r2
bgt 3b
@@ -144,16 +135,13 @@ T cmp r7, #0
vld1.8 {d6, d7}, [r1], r2
vext.8 d5, d4, d5, #1
vext.8 d7, d6, d7, #1
-
-5: pld [r1]
+ pld [r1]
subs r3, r3, #2
vmull.u8 q8, d4, d0
vmlal.u8 q8, d5, d1
- vld1.8 {d4, d5}, [r1], r2
vmull.u8 q9, d6, d0
vmlal.u8 q9, d7, d1
- pld [r1]
- vext.8 d5, d4, d5, #1
+ pld [r1, r2]
.ifc \codec,h264
vrshrn.u16 d16, q8, #6
vrshrn.u16 d17, q9, #6
@@ -168,11 +156,9 @@ T cmp r7, #0
vld1.8 {d21}, [lr,:64], r2
vrhadd.u8 q8, q8, q10
.endif
- vld1.8 {d6, d7}, [r1], r2
- vext.8 d7, d6, d7, #1
vst1.8 {d16}, [r0,:64], r2
vst1.8 {d17}, [r0,:64], r2
- bgt 5b
+ bgt 4b
pop {r4-r7, pc}
endfunc
@@ -209,33 +195,29 @@ T cmp r7, #0
beq 2f
- add r5, r1, r2
-
vdup.8 d0, r4
- lsl r4, r2, #1
vdup.8 d1, r12
- vld1.8 {d4}, [r1], r4
+ vld1.8 {d4}, [r1], r2
vdup.8 d2, r6
- vld1.8 {d6}, [r5], r4
vdup.8 d3, r7
vext.8 d5, d4, d5, #1
- vext.8 d7, d6, d7, #1
vtrn.32 d4, d5
- vtrn.32 d6, d7
vtrn.32 d0, d1
vtrn.32 d2, d3
-1: pld [r5]
+1: vld1.8 {d6}, [r1], r2
+ vext.8 d7, d6, d7, #1
+ vtrn.32 d6, d7
vmull.u8 q8, d4, d0
vmlal.u8 q8, d6, d2
- vld1.8 {d4}, [r1], r4
+ vld1.8 {d4}, [r1], r2
vext.8 d5, d4, d5, #1
vtrn.32 d4, d5
+ pld [r1]
vmull.u8 q9, d6, d0
vmlal.u8 q9, d4, d2
- vld1.8 {d6}, [r5], r4
vadd.i16 d16, d16, d17
vadd.i16 d17, d18, d19
.ifc \codec,h264
@@ -245,14 +227,12 @@ T cmp r7, #0
vshrn.u16 d16, q8, #6
.endif
subs r3, r3, #2
- pld [r1]
+ pld [r1, r2]
.ifc \type,avg
vld1.32 {d20[0]}, [lr,:32], r2
vld1.32 {d20[1]}, [lr,:32], r2
vrhadd.u8 d16, d16, d20
.endif
- vext.8 d7, d6, d7, #1
- vtrn.32 d6, d7
vst1.32 {d16[0]}, [r0,:32], r2
vst1.32 {d16[1]}, [r0,:32], r2
bgt 1b
@@ -268,18 +248,15 @@ T cmp r7, #0
beq 4f
vext.32 d1, d0, d1, #1
- add r5, r1, r2
- lsl r4, r2, #1
- vld1.32 {d4[0]}, [r1], r4
- vld1.32 {d4[1]}, [r5], r4
+ vld1.32 {d4[0]}, [r1], r2
-3: pld [r5]
+3: vld1.32 {d4[1]}, [r1], r2
vmull.u8 q8, d4, d0
- vld1.32 {d4[0]}, [r1], r4
+ vld1.32 {d4[0]}, [r1], r2
vmull.u8 q9, d4, d1
- vld1.32 {d4[1]}, [r5], r4
vadd.i16 d16, d16, d17
vadd.i16 d17, d18, d19
+ pld [r1]
.ifc \codec,h264
vrshrn.u16 d16, q8, #6
.else
@@ -292,7 +269,7 @@ T cmp r7, #0
vrhadd.u8 d16, d16, d20
.endif
subs r3, r3, #2
- pld [r1]
+ pld [r1, r2]
vst1.32 {d16[0]}, [r0,:32], r2
vst1.32 {d16[1]}, [r0,:32], r2
bgt 3b
@@ -305,13 +282,9 @@ T cmp r7, #0
vext.8 d7, d6, d7, #1
vtrn.32 d4, d5
vtrn.32 d6, d7
-
-5: vmull.u8 q8, d4, d0
+ vmull.u8 q8, d4, d0
vmull.u8 q9, d6, d0
subs r3, r3, #2
- vld1.8 {d4}, [r1], r2
- vext.8 d5, d4, d5, #1
- vtrn.32 d4, d5
vadd.i16 d16, d16, d17
vadd.i16 d17, d18, d19
pld [r1]
@@ -326,13 +299,10 @@ T cmp r7, #0
vld1.32 {d20[1]}, [lr,:32], r2
vrhadd.u8 d16, d16, d20
.endif
- vld1.8 {d6}, [r1], r2
- vext.8 d7, d6, d7, #1
- vtrn.32 d6, d7
pld [r1]
vst1.32 {d16[0]}, [r0,:32], r2
vst1.32 {d16[1]}, [r0,:32], r2
- bgt 5b
+ bgt 4b
pop {r4-r7, pc}
endfunc
--
1.7.2.5

View File

@ -1,24 +0,0 @@
From 9066d83f0f237d90fe0c2d9b6202bb8cd59a6562 Mon Sep 17 00:00:00 2001
From: Allan Kristensen <allank@tigerdyr.com>
Date: Fri, 21 Dec 2012 21:04:18 +0100
Subject: [PATCH 1/1] [ffmpeg] fixed missing S_DVBSUB subtitles
---
libavformat/matroska.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libavformat/matroska.c b/libavformat/matroska.c
index 2f5b617..11c2fa5 100644
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -59,6 +59,7 @@ const CodecTags ff_mkv_codec_tags[]={
{"S_ASS" , CODEC_ID_SSA},
{"S_SSA" , CODEC_ID_SSA},
{"S_VOBSUB" , CODEC_ID_DVD_SUBTITLE},
+ {"S_DVBSUB" , CODEC_ID_DVB_SUBTITLE},
{"S_HDMV/PGS" , CODEC_ID_HDMV_PGS_SUBTITLE},
{"V_DIRAC" , CODEC_ID_DIRAC},
--
1.8.0

View File

@ -1,337 +0,0 @@
From b2d3b83a73d71833f84485adb8a6f4c0959b4c4e Mon Sep 17 00:00:00 2001
From: Harald Axmann <harald.axmann@hotmail.com>
Date: Sun, 16 Dec 2012 16:07:36 +0100
Subject: [PATCH] lavf: Provide a monotonic timestamp to the outside world
This detects and removes single timestamp wraps, which fixes seeking for affected video files.
---
libavformat/avformat.h | 37 +++++++++++
libavformat/options.c | 1 +
libavformat/utils.c | 123 ++++++++++++++++++++++++++++++++++---
3 files changed, 151 insertions(+), 10 deletions(-)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index c76ac71..40f71cb 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -627,6 +627,13 @@ enum AVStreamParseType {
#define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100 /**< stream for visual impaired audiences */
#define AV_DISPOSITION_CLEAN_EFFECTS 0x0200 /**< stream without voice */
+/*
+ * Options for behavior on timestamp wrap detection.
+ */
+#define AV_PTS_WRAP_IGNORE 0 ///< ignore the wrap
+#define AV_PTS_WRAP_ADD_OFFSET 1 ///< add the format specific offset on wrap detection
+#define AV_PTS_WRAP_SUB_OFFSET -1 ///< subtract the format specific offset on wrap detection
+
/**
* Stream structure.
* New fields can be added to the end with minor version bumps.
@@ -857,6 +864,24 @@ enum AVStreamParseType {
int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */
#endif
+
+ /**
+ * Internal data to check for wrapping of the time stamp
+ */
+ int64_t pts_wrap_reference;
+
+ /**
+ * Options for behavior, when a wrap is detected.
+ *
+ * Defined by AV_PTS_WRAP_ values.
+ *
+ * If correction is enabled, there are two possibilities:
+ * If the first time stamp is near the wrap point, the wrap offset
+ * will be subtracted, which will create negative time stamps.
+ * Otherwise the offset will be added.
+ */
+ int pts_wrap_behavior;
+
} AVStream;
#define AV_PROGRAM_RUNNING 1
@@ -878,6 +903,10 @@ enum AVStreamParseType {
int program_num;
int pmt_pid;
int pcr_pid;
+
+ int64_t pts_wrap_reference; ///< reference dts for wrap detection
+ int pts_wrap_behavior; ///< behavior on wrap detection
+
} AVProgram;
#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present
@@ -1234,6 +1263,14 @@ enum AVStreamParseType {
/* av_seek_frame() support */
int64_t data_offset; /**< offset of the first packet */
#endif
+
+ /**
+ * Correct single timestamp overflows
+ * - encoding: unused
+ * - decoding: Set by user via AVOPtions (NO direct access)
+ */
+ unsigned int correct_ts_overflow;
+
} AVFormatContext;
typedef struct AVPacketList {
diff --git a/libavformat/options.c b/libavformat/options.c
index 31acbd3..666d05e 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -127,6 +127,7 @@ static const AVClass *format_child_class_next(const AVClass *prev)
{"careful", "consider things that violate the spec and have not been seen in the wild as errors", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_CAREFUL }, INT_MIN, INT_MAX, D, "err_detect"},
{"compliant", "consider all spec non compliancies as errors", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_COMPLIANT }, INT_MIN, INT_MAX, D, "err_detect"},
{"aggressive", "consider things that a sane encoder shouldnt do as an error", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_AGGRESSIVE }, INT_MIN, INT_MAX, D, "err_detect"},
+{"correct_ts_overflow", "correct single timestamp overflows", OFFSET(correct_ts_overflow), AV_OPT_TYPE_INT, {.dbl = 1}, 0, 1, D},
{NULL},
};
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 63f89dd..89e5ed4 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -122,6 +122,27 @@ static void frac_add(AVFrac *f, int64_t incr)
f->num = num;
}
+/**
+ * Wrap a given time stamp, if there is an indication for an overflow
+ *
+ * @param st stream
+ * @param timestamp the time stamp to wrap
+ * @return resulting time stamp
+ */
+static int64_t wrap_timestamp(AVStream *st, int64_t timestamp)
+{
+ if (st->pts_wrap_behavior != AV_PTS_WRAP_IGNORE &&
+ st->pts_wrap_reference != AV_NOPTS_VALUE && timestamp != AV_NOPTS_VALUE) {
+ if (st->pts_wrap_behavior == AV_PTS_WRAP_ADD_OFFSET &&
+ timestamp < st->pts_wrap_reference)
+ return timestamp + (1LL<<st->pts_wrap_bits);
+ else if (st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET &&
+ timestamp >= st->pts_wrap_reference)
+ return timestamp - (1LL<<st->pts_wrap_bits);
+ }
+ return timestamp;
+}
+
/** head of registered input format linked list */
static AVInputFormat *first_iformat = NULL;
/** head of registered output format linked list */
@@ -798,6 +819,8 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt)
}
st= s->streams[pkt->stream_index];
+ pkt->dts = wrap_timestamp(st, pkt->dts);
+ pkt->pts = wrap_timestamp(st, pkt->pts);
switch(st->codec->codec_type){
case AVMEDIA_TYPE_VIDEO:
@@ -948,8 +971,67 @@ static int is_intra_only(AVCodecContext *enc){
return 0;
}
+static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_index)
+{
+ if (s->correct_ts_overflow && st->pts_wrap_bits != 64 &&
+ st->pts_wrap_reference == AV_NOPTS_VALUE && st->first_dts != AV_NOPTS_VALUE) {
+ int i;
+
+ // reference time stamp should be 60 s before first time stamp
+ int64_t pts_wrap_reference = st->first_dts - av_rescale(60, st->time_base.den, st->time_base.num);
+ // if first time stamp is not more than 1/8 and 60s before the wrap point, subtract rather than add wrap offset
+ int pts_wrap_behavior = (st->first_dts < (1LL<<st->pts_wrap_bits) - (1LL<<st->pts_wrap_bits-3)) ||
+ (st->first_dts < (1LL<<st->pts_wrap_bits) - av_rescale(60, st->time_base.den, st->time_base.num)) ?
+ AV_PTS_WRAP_ADD_OFFSET : AV_PTS_WRAP_SUB_OFFSET;
+
+ AVProgram *first_program = av_find_program_from_stream(s, NULL, stream_index);
+
+ if (!first_program) {
+ int default_stream_index = av_find_default_stream_index(s);
+ if (s->streams[default_stream_index]->pts_wrap_reference == AV_NOPTS_VALUE) {
+ for (i=0; i<s->nb_streams; i++) {
+ s->streams[i]->pts_wrap_reference = pts_wrap_reference;
+ s->streams[i]->pts_wrap_behavior = pts_wrap_behavior;
+ }
+ }
+ else {
+ st->pts_wrap_reference = s->streams[default_stream_index]->pts_wrap_reference;
+ st->pts_wrap_behavior = s->streams[default_stream_index]->pts_wrap_behavior;
+ }
+ }
+ else {
+ AVProgram *program = first_program;
+ while (program) {
+ if (program->pts_wrap_reference != AV_NOPTS_VALUE) {
+ pts_wrap_reference = program->pts_wrap_reference;
+ pts_wrap_behavior = program->pts_wrap_behavior;
+ break;
+ }
+ program = av_find_program_from_stream(s, program, stream_index);
+ }
+
+ // update every program with differing pts_wrap_reference
+ program = first_program;
+ while(program) {
+ if (program->pts_wrap_reference != pts_wrap_reference) {
+ for (i=0; i<program->nb_stream_indexes; i++) {
+ s->streams[program->stream_index[i]]->pts_wrap_reference = pts_wrap_reference;
+ s->streams[program->stream_index[i]]->pts_wrap_behavior = pts_wrap_behavior;
+ }
+
+ program->pts_wrap_reference = pts_wrap_reference;
+ program->pts_wrap_behavior = pts_wrap_behavior;
+ }
+ program = av_find_program_from_stream(s, program, stream_index);
+ }
+ }
+ return 1;
+ }
+ return 0;
+}
+
static void update_initial_timestamps(AVFormatContext *s, int stream_index,
- int64_t dts, int64_t pts)
+ int64_t dts, int64_t pts, AVPacket *pkt)
{
AVStream *st= s->streams[stream_index];
AVPacketList *pktl= s->packet_buffer;
@@ -973,6 +1055,16 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
if(st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != AV_NOPTS_VALUE)
st->start_time= pktl->pkt.pts;
}
+
+ if (update_wrap_reference(s, st, stream_index) && st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET) {
+ // correct first time stamps to negative values
+ st->first_dts = wrap_timestamp(st, st->first_dts);
+ st->cur_dts = wrap_timestamp(st, st->cur_dts);
+ pkt->dts = wrap_timestamp(st, pkt->dts);
+ pkt->pts = wrap_timestamp(st, pkt->pts);
+ pts = wrap_timestamp(st, pts);
+ }
+
if (st->start_time == AV_NOPTS_VALUE)
st->start_time = pts;
}
@@ -1104,7 +1196,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
/* PTS = presentation timestamp */
if (pkt->dts == AV_NOPTS_VALUE)
pkt->dts = st->last_IP_pts;
- update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts);
+ update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts, pkt);
if (pkt->dts == AV_NOPTS_VALUE)
pkt->dts = st->cur_dts;
@@ -1131,7 +1223,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
/* presentation is not delayed : PTS and DTS are the same */
if(pkt->pts == AV_NOPTS_VALUE)
pkt->pts = pkt->dts;
- update_initial_timestamps(s, pkt->stream_index, pkt->pts, pkt->pts);
+ update_initial_timestamps(s, pkt->stream_index, pkt->pts, pkt->pts, pkt);
if(pkt->pts == AV_NOPTS_VALUE)
pkt->pts = st->cur_dts;
pkt->dts = pkt->pts;
@@ -1147,7 +1239,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
if(pkt->dts == AV_NOPTS_VALUE)
pkt->dts= st->pts_buffer[0];
if(st->codec->codec_id == CODEC_ID_H264){ // we skipped it above so we try here
- update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts); // this should happen on the first packet
+ update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts, pkt); // this should happen on the first packet
}
if(pkt->dts > st->cur_dts)
st->cur_dts = pkt->dts;
@@ -1550,6 +1642,7 @@ int ff_add_index_entry(AVIndexEntry **index_entries,
int av_add_index_entry(AVStream *st,
int64_t pos, int64_t timestamp, int size, int distance, int flags)
{
+ timestamp = wrap_timestamp(st, timestamp);
return ff_add_index_entry(&st->index_entries, &st->nb_index_entries,
&st->index_entries_allocated_size, pos,
timestamp, size, distance, flags);
@@ -1602,6 +1695,12 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts
}
#endif
+static int64_t ff_read_timestamp(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit,
+ int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t ))
+{
+ return wrap_timestamp(s->streams[stream_index], read_timestamp(s, stream_index, ppos, pos_limit));
+}
+
int ff_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags)
{
AVInputFormat *avif= s->iformat;
@@ -1689,7 +1788,7 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts,
if(ts_min == AV_NOPTS_VALUE){
pos_min = s->data_offset;
- ts_min = read_timestamp(s, stream_index, &pos_min, INT64_MAX);
+ ts_min = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
if (ts_min == AV_NOPTS_VALUE)
return -1;
}
@@ -1705,7 +1804,7 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts,
pos_max = filesize - 1;
do{
pos_max -= step;
- ts_max = read_timestamp(s, stream_index, &pos_max, pos_max + step);
+ ts_max = ff_read_timestamp(s, stream_index, &pos_max, pos_max + step, read_timestamp);
step += step;
}while(ts_max == AV_NOPTS_VALUE && pos_max >= step);
if (ts_max == AV_NOPTS_VALUE)
@@ -1713,7 +1812,7 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts,
for(;;){
int64_t tmp_pos= pos_max + 1;
- int64_t tmp_ts= read_timestamp(s, stream_index, &tmp_pos, INT64_MAX);
+ int64_t tmp_ts= ff_read_timestamp(s, stream_index, &tmp_pos, INT64_MAX, read_timestamp);
if(tmp_ts == AV_NOPTS_VALUE)
break;
ts_max= tmp_ts;
@@ -1760,7 +1859,7 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts,
pos= pos_limit;
start_pos= pos;
- ts = read_timestamp(s, stream_index, &pos, INT64_MAX); //may pass pos_limit instead of -1
+ ts = ff_read_timestamp(s, stream_index, &pos, INT64_MAX, read_timestamp); //may pass pos_limit instead of -1
if(pos == pos_max)
no_change++;
else
@@ -1788,9 +1887,9 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts,
ts = (flags & AVSEEK_FLAG_BACKWARD) ? ts_min : ts_max;
#if 0
pos_min = pos;
- ts_min = read_timestamp(s, stream_index, &pos_min, INT64_MAX);
+ ts_min = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
pos_min++;
- ts_max = read_timestamp(s, stream_index, &pos_min, INT64_MAX);
+ ts_max = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp);
av_dlog(s, "pos=0x%"PRIx64" %"PRId64"<=%"PRId64"<=%"PRId64"\n",
pos, ts_min, target_ts, ts_max);
#endif
@@ -2992,6 +3091,8 @@ AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)
st->cur_dts = 0;
st->first_dts = AV_NOPTS_VALUE;
st->probe_packets = MAX_PROBE_PACKETS;
+ st->pts_wrap_reference = AV_NOPTS_VALUE;
+ st->pts_wrap_behavior = AV_PTS_WRAP_IGNORE;
/* default pts setting is MPEG-like */
avpriv_set_pts_info(st, 33, 1, 90000);
@@ -3025,6 +3126,8 @@ AVProgram *av_new_program(AVFormatContext *ac, int id)
program->discard = AVDISCARD_NONE;
}
program->id = id;
+ program->pts_wrap_reference = AV_NOPTS_VALUE;
+ program->pts_wrap_behavior = AV_PTS_WRAP_IGNORE;
return program;
}
--
1.7.10

View File

@ -1,28 +0,0 @@
From 06d713fefaf19cb4dfb83126ba1c078d6dcabc67 Mon Sep 17 00:00:00 2001
From: xbmc <fernetmenta@online.de>
Date: Tue, 25 Dec 2012 08:35:36 +0100
Subject: [PATCH] ffmpeg: backport latm: fix initialization on some streams
when no extradata is available:
d039b6074ca68da9b6dc88d8bb40056fee9fecb6
---
libavcodec/aacdec.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 5c6404e..ad2991b 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -2403,7 +2403,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
if (bits_consumed < 0)
return AVERROR_INVALIDDATA;
- if (ac->m4ac.sample_rate != m4ac.sample_rate ||
+ if (!latmctx->initialized ||
+ ac->m4ac.sample_rate != m4ac.sample_rate ||
ac->m4ac.chan_config != m4ac.chan_config) {
av_log(avctx, AV_LOG_INFO, "audio config changed\n");
--
1.7.10

View File

@ -1,284 +0,0 @@
From 3b1409c1a1f0ce486f95087fa0b6ff5bfb841464 Mon Sep 17 00:00:00 2001
From: GreenOnyx <gonyx@mchsi.com>
Date: Thu, 27 Dec 2012 00:18:40 -0600
Subject: [PATCH] ffmpeg: Fixed forced subtitles display in PGS stream
Associated ffmpeg commits:
https://github.com/FFmpeg/FFmpeg/commit/36436a4032b022f5439fa86a0986065d24cd51fd
Add option forced_subs_only for Bluray subtitles.
2012-01-30 04:25:59
https://github.com/FFmpeg/FFmpeg/commit/1885ffb03d0af28e6bac2bcc8725fa15b93f6ac9
PGS subtitles: Expose forced flag
2012-10-20 11:56:11
https://github.com/FFmpeg/FFmpeg/commit/1c5805521c3e406886341d752ebf38f8d41e1d13
PGS subtitles: Set AVSubtitle pts value
2012-11-02 11:30:39
https://github.com/FFmpeg/FFmpeg/commit/6549a9b75333027f66cdaac450a66b6a6186fc6e
pgssubdec: remove unused variable
2012-11-28 10:20:08
https://github.com/FFmpeg/FFmpeg/commit/1f46b50a9591f68b697e943f829c79a4f4829dd6
Added AVClass for AVSubtitleRect
2012-04-18 01:08:25
---
libavcodec/avcodec.h | 18 +++++++++++++
libavcodec/dvdsubdec.c | 1 +
libavcodec/options.c | 25 +++++++++++++++++
libavcodec/pgssubdec.c | 53 ++++++++++++++++++++++++++-----------
4 files changed, 81 insertions(+), 16 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 6996c92..585414b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3245,6 +3245,12 @@ enum AVFieldOrder {
int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
int64_t pts_correction_last_pts; /// PTS of the last frame
int64_t pts_correction_last_dts; /// DTS of the last frame
+ /**
+ * Requests that only forced subpictures be decoded.
+ * - decoding: set by user
+ * - encoding: unused
+ */
+ int forced_subs_only;
} AVCodecContext;
@@ -3488,6 +3494,8 @@ enum AVSubtitleType {
SUBTITLE_ASS,
};
+#define AV_SUBTITLE_FLAG_FORCED 0x00000001
+
typedef struct AVSubtitleRect {
int x; ///< top left corner of pict, undefined when pict is not set
int y; ///< top left corner of pict, undefined when pict is not set
@@ -3510,6 +3518,8 @@ enum AVSubtitleType {
* struct.
*/
char *ass;
+
+ int flags;
} AVSubtitleRect;
typedef struct AVSubtitle {
@@ -4895,6 +4905,14 @@ enum AVLockOp {
const AVClass *avcodec_get_frame_class(void);
/**
+ * Get the AVClass for AVSubtitleRect. It can be used in combination with
+ * AV_OPT_SEARCH_FAKE_OBJ for examining options.
+ *
+ * @see av_opt_find().
+ */
+const AVClass *avcodec_get_subtitle_rect_class(void);
+
+/**
* @return a positive value if s is open (i.e. avcodec_open2() was called on it
* with no corresponding avcodec_close()), 0 otherwise.
*/
diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index d0d13ee..46a0b8d 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -375,6 +375,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
sub_header->rects[0]->h = h;
sub_header->rects[0]->type = SUBTITLE_BITMAP;
sub_header->rects[0]->pict.linesize[0] = w;
+ sub_header->rects[0]->flags = is_menu ? AV_SUBTITLE_FLAG_FORCED : 0;
}
}
if (next_cmd_pos < cmd_pos) {
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 5f940a0..ae62e75 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -730,3 +730,28 @@ const AVClass *avcodec_get_frame_class(void)
{
return &av_frame_class;
}
+
+#define SROFFSET(x) offsetof(AVSubtitleRect,x)
+
+static const AVOption subtitle_rect_options[]={
+{"x", "", SROFFSET(x), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
+{"y", "", SROFFSET(y), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
+{"w", "", SROFFSET(w), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
+{"h", "", SROFFSET(h), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
+{"type", "", SROFFSET(type), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
+{"flags", "", SROFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, 1, 0, "flags"},
+{"forced", "", SROFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, 1, 0},
+{NULL},
+};
+
+static const AVClass av_subtitle_rect_class = {
+ .class_name = "AVSubtitleRect",
+ .item_name = NULL,
+ .option = subtitle_rect_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+const AVClass *avcodec_get_subtitle_rect_class(void)
+{
+ return &av_subtitle_rect_class;
+}
\ No newline at end of file
diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
index 02e650a..83d7f43 100644
--- a/libavcodec/pgssubdec.c
+++ b/libavcodec/pgssubdec.c
@@ -29,6 +29,7 @@
#include "bytestream.h"
#include "libavutil/colorspace.h"
#include "libavutil/imgutils.h"
+#include "libavutil/opt.h"
#define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
@@ -44,12 +45,14 @@ enum SegmentType {
int x;
int y;
int picture_id;
+ int composition;
} PGSSubPictureReference;
typedef struct PGSSubPresentation {
int id_number;
int object_count;
PGSSubPictureReference *objects;
+ int64_t pts;
} PGSSubPresentation;
typedef struct PGSSubPicture {
@@ -61,10 +64,11 @@ enum SegmentType {
} PGSSubPicture;
typedef struct PGSSubContext {
+ AVClass *class;
PGSSubPresentation presentation;
uint32_t clut[256];
PGSSubPicture pictures[UINT16_MAX];
- int64_t pts;
+ int forced_subs_only;
} PGSSubContext;
static av_cold int init_decoder(AVCodecContext *avctx)
@@ -284,10 +288,10 @@ static void parse_palette_segment(AVCodecContext *avctx,
* @param buf pointer to the packet to process
* @param buf_size size of packet to process
* @todo TODO: Implement cropping
- * @todo TODO: Implement forcing of subtitles
*/
static void parse_presentation_segment(AVCodecContext *avctx,
- const uint8_t *buf, int buf_size)
+ const uint8_t *buf, int buf_size,
+ int64_t pts)
{
PGSSubContext *ctx = avctx->priv_data;
@@ -296,6 +300,8 @@ static void parse_presentation_segment(AVCodecContext *avctx,
uint16_t object_index;
+ ctx->presentation.pts = pts;
+
av_dlog(avctx, "Video Dimensions %dx%d\n",
w, h);
if (av_image_check_size(w, h, 0, avctx) >= 0)
@@ -336,12 +342,10 @@ static void parse_presentation_segment(AVCodecContext *avctx,
PGSSubPictureReference *reference = &ctx->presentation.objects[object_index];
reference->picture_id = bytestream_get_be16(&buf);
- /*
- * Skip 2 bytes of unknown:
- * window_id_ref,
- * composition_flag (0x80 - object cropped, 0x40 - object forced)
- */
- buf += 2;
+ /* Skip window_id_ref */
+ buf++;
+ /* composition_flag (0x80 - object cropped, 0x40 - object forced) */
+ reference->composition = bytestream_get_byte(&buf);
reference->x = bytestream_get_be16(&buf);
reference->y = bytestream_get_be16(&buf);
@@ -388,10 +392,10 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
* not been cleared by a subsequent empty display command.
*/
- pts = ctx->pts != AV_NOPTS_VALUE ? ctx->pts : sub->pts;
+ pts = ctx->presentation.pts != AV_NOPTS_VALUE ? ctx->presentation.pts : sub->pts;
memset(sub, 0, sizeof(*sub));
sub->pts = pts;
- ctx->pts = AV_NOPTS_VALUE;
+ ctx->presentation.pts = AV_NOPTS_VALUE;
// Blank if last object_count was 0.
if (!ctx->presentation.object_count)
@@ -427,6 +431,10 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
sub->rects[rect]->nb_colors = 256;
sub->rects[rect]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
+ /* Copy the forced flag */
+ sub->rects[rect]->flags = (ctx->presentation.objects[rect].composition & 0x40) != 0 ? AV_SUBTITLE_FLAG_FORCED : 0;
+
+ if (!ctx->forced_subs_only || ctx->presentation.objects[rect].composition & 0x40)
memcpy(sub->rects[rect]->pict.data[1], ctx->clut, sub->rects[rect]->nb_colors * sizeof(uint32_t));
}
@@ -436,7 +444,6 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
static int decode(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
- PGSSubContext *ctx = avctx->priv_data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AVSubtitle *sub = data;
@@ -483,8 +490,7 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size,
parse_picture_segment(avctx, buf, segment_length);
break;
case PRESENTATION_SEGMENT:
- parse_presentation_segment(avctx, buf, segment_length);
- ctx->pts = sub->pts;
+ parse_presentation_segment(avctx, buf, segment_length, sub->pts);
break;
case WINDOW_SEGMENT:
/*
@@ -511,6 +517,20 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size,
return buf_size;
}
+#define OFFSET(x) offsetof(PGSSubContext, x)
+#define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
+static const AVOption options[] = {
+ {"forced_subs_only", "Only show forced subtitles", OFFSET(forced_subs_only), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, SD},
+ { NULL },
+};
+
+static const AVClass pgsdec_class = {
+ .class_name = "PGS subtitle decoder",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_pgssub_decoder = {
.name = "pgssub",
.type = AVMEDIA_TYPE_SUBTITLE,
@@ -519,5 +539,6 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size,
.init = init_decoder,
.close = close_decoder,
.decode = decode,
- .long_name = NULL_IF_CONFIG_SMALL("HDMV Presentation Graphic Stream subtitles"),
-};
+ .long_name = NULL_IF_CONFIG_SMALL("HDMV Presentation Graphic Stream subtitles"),
+ .priv_class = &pgsdec_class,
+};
\ No newline at end of file
--
1.7.10

View File

@ -1,13 +0,0 @@
diff -Naur ffmpeg-0.10.7/libavcodec/h264.c ffmpeg-0.10.7.patch/libavcodec/h264.c
--- ffmpeg-0.10.7/libavcodec/h264.c 2013-04-10 03:52:33.000000000 +0200
+++ ffmpeg-0.10.7.patch/libavcodec/h264.c 2013-09-09 17:25:55.377208927 +0200
@@ -3962,8 +3962,7 @@
continue;
}
- //FIXME do not discard SEI id
- if(avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0)
+ if (avctx->skip_frame >= AVDISCARD_NONREF && h->nal_ref_idc == 0 && h->nal_unit_type != NAL_SEI)
continue;
again:

View File

@ -1,40 +0,0 @@
From 90ac611930e202c8255887c6b3e82ff97a1117f0 Mon Sep 17 00:00:00 2001
From: popcornmix <popcornmix@gmail.com>
Date: Thu, 22 Aug 2013 14:34:37 +0100
Subject: [PATCH] h264_parser: Initialize the h264dsp context in the parser as
well
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Each AVStream struct for an H.264 elementary stream actually has two
copies of the H264DSPContext struct (and in fact all the other members
of H264Context as well):
((H264Context *) ((AVStream *)st)->codec->priv_data)->h264dsp
((H264Context *) ((AVStream *)st)->parser->priv_data)->h264dsp
but only the first of these was actually being initialised. This
prevented the addition of platform-specific implementations of
parser-related functions.
Signed-off-by: Martin Storsjö <martin@martin.st>
---
libavcodec/h264_parser.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index c9dea81..98e2844 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -377,6 +377,7 @@ static int init(AVCodecParserContext *s)
H264Context *h = s->priv_data;
h->thread_context[0] = h;
h->s.slice_context_count = 1;
+ ff_h264dsp_init(&h->h264dsp, 8, 1);
return 0;
}
--
1.8.1.6

View File

@ -1,129 +0,0 @@
From c58d69bea87c77c7a1e8221624137beaaa670586 Mon Sep 17 00:00:00 2001
From: popcornmix <popcornmix@gmail.com>
Date: Thu, 22 Aug 2013 14:37:18 +0100
Subject: [PATCH] h264dsp: Factorize code into a new function,
h264_find_start_code_candidate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This performs the start code search which was previously part of
h264_find_frame_end() - the most CPU intensive part of the function.
By itself, this results in a performance regression:
Before After
Mean StdDev Mean StdDev Change
Overall time 2925.6 26.2 3068.5 31.7 -4.7%
but this can more than be made up for by platform-optimised
implementations of the function.
Signed-off-by: Martin Storsjö <martin@martin.st>
---
libavcodec/h264_parser.c | 21 +++------------------
libavcodec/h264dsp.c | 29 +++++++++++++++++++++++++++++
libavcodec/h264dsp.h | 9 +++++++++
3 files changed, 41 insertions(+), 18 deletions(-)
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 98e2844..41c874d 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -65,24 +65,9 @@ static int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_si
}
if(state==7){
-#if HAVE_FAST_UNALIGNED
- /* we check i<buf_size instead of i+3/7 because its simpler
- * and there should be FF_INPUT_BUFFER_PADDING_SIZE bytes at the end
- */
-# if HAVE_FAST_64BIT
- while(i<next_avc && !((~*(const uint64_t*)(buf+i) & (*(const uint64_t*)(buf+i) - 0x0101010101010101ULL)) & 0x8080808080808080ULL))
- i+=8;
-# else
- while(i<next_avc && !((~*(const uint32_t*)(buf+i) & (*(const uint32_t*)(buf+i) - 0x01010101U)) & 0x80808080U))
- i+=4;
-# endif
-#endif
- for(; i<next_avc; i++){
- if(!buf[i]){
- state=2;
- break;
- }
- }
+ i += h->h264dsp.h264_find_start_code_candidate(buf + i, buf_size - i);
+ if (i < buf_size)
+ state = 2;
}else if(state<=2){
if(buf[i]==1) state^= 5; //2->7, 1->4, 0->5
else if(buf[i]) state = 7;
diff --git a/libavcodec/h264dsp.c b/libavcodec/h264dsp.c
index bd35aa3..0703172 100644
--- a/libavcodec/h264dsp.c
+++ b/libavcodec/h264dsp.c
@@ -41,6 +41,34 @@
#include "h264dsp_template.c"
#undef BIT_DEPTH
+static int h264_find_start_code_candidate_c(const uint8_t *buf, int size)
+{
+ int i = 0;
+#if HAVE_FAST_UNALIGNED
+ /* we check i < size instead of i + 3 / 7 because it is
+ * simpler and there must be FF_INPUT_BUFFER_PADDING_SIZE
+ * bytes at the end.
+ */
+#if HAVE_FAST_64BIT
+ while (i < size &&
+ !((~*(const uint64_t *)(buf + i) &
+ (*(const uint64_t *)(buf + i) - 0x0101010101010101ULL)) &
+ 0x8080808080808080ULL))
+ i += 8;
+#else
+ while (i < size &&
+ !((~*(const uint32_t *)(buf + i) &
+ (*(const uint32_t *)(buf + i) - 0x01010101U)) &
+ 0x80808080U))
+ i += 4;
+#endif
+#endif
+ for (; i < size; i++)
+ if (!buf[i])
+ break;
+ return i;
+}
+
void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc)
{
#undef FUNC
@@ -110,6 +138,7 @@ void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_fo
H264_DSP(8);
break;
}
+ c->h264_find_start_code_candidate = h264_find_start_code_candidate_c;
if (ARCH_ARM) ff_h264dsp_init_arm(c, bit_depth, chroma_format_idc);
if (HAVE_ALTIVEC) ff_h264dsp_init_ppc(c, bit_depth, chroma_format_idc);
diff --git a/libavcodec/h264dsp.h b/libavcodec/h264dsp.h
index 490a936..1d172f1 100644
--- a/libavcodec/h264dsp.h
+++ b/libavcodec/h264dsp.h
@@ -74,6 +74,15 @@ typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int h
void (*h264_idct_add16intra)(uint8_t *dst/*align 16*/, const int *blockoffset, DCTELEM *block/*align 16*/, int stride, const uint8_t nnzc[15*8]);
void (*h264_luma_dc_dequant_idct)(DCTELEM *output, DCTELEM *input/*align 16*/, int qmul);
void (*h264_chroma_dc_dequant_idct)(DCTELEM *block, int qmul);
+
+ /**
+ * Search buf from the start for up to size bytes. Return the index
+ * of a zero byte, or >= size if not found. Ideally, use lookahead
+ * to filter out any zero bytes that are known to not be followed by
+ * one or more further zero bytes and a one byte. Better still, filter
+ * out any bytes that form the trailing_zero_8bits syntax element too.
+ */
+ int (*h264_find_start_code_candidate)(const uint8_t *buf, int size);
}H264DSPContext;
void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc);
--
1.8.1.6

View File

@ -1,321 +0,0 @@
From 4b8f90c0702324a9fcc3909c8bf7d80f090c41ba Mon Sep 17 00:00:00 2001
From: popcornmix <popcornmix@gmail.com>
Date: Thu, 22 Aug 2013 14:39:21 +0100
Subject: [PATCH] arm: Add assembly version of h264_find_start_code_candidate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Before After
Mean StdDev Mean StdDev Change
This function 508.8 23.4 185.4 9.0 +174.4%
Overall 3068.5 31.7 2752.1 29.4 +11.5%
In combination with the preceding patch:
Before After
Mean StdDev Mean StdDev Change
Overall 2925.6 26.2 2752.1 29.4 +6.3%
Signed-off-by: Martin Storsjö <martin@martin.st>
---
libavcodec/arm/Makefile | 1 +
libavcodec/arm/h264dsp_armv6.S | 253 +++++++++++++++++++++++++++
libavcodec/arm/h264dsp_init_arm.c | 4 +
3 files changed, 258 insertions(+)
create mode 100644 libavcodec/arm/h264dsp_armv6.S
diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile
index 798dfe3..8f2b683 100644
--- a/libavcodec/arm/Makefile
+++ b/libavcodec/arm/Makefile
@@ -4,6 +4,7 @@ OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_init_arm.o \
OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_init_arm.o \
ARMV6-OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_armv6.o
+ARMV6-OBJS-$(CONFIG_H264DSP) += arm/h264dsp_armv6.o
OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_init_arm.o
ARMV6-OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_fixed_armv6.o
diff --git a/libavcodec/arm/h264dsp_armv6.S b/libavcodec/arm/h264dsp_armv6.S
new file mode 100644
index 0000000..c2cafc2
--- /dev/null
+++ b/libavcodec/arm/h264dsp_armv6.S
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2013 RISC OS Open Ltd
+ * Author: Ben Avison <bavison@riscosopen.org>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "asm.S"
+
+RESULT .req a1
+BUF .req a1
+SIZE .req a2
+PATTERN .req a3
+PTR .req a4
+DAT0 .req v1
+DAT1 .req v2
+DAT2 .req v3
+DAT3 .req v4
+TMP0 .req v5
+TMP1 .req v6
+TMP2 .req ip
+TMP3 .req lr
+
+#define PRELOAD_DISTANCE 4
+
+.macro innerloop4
+ ldr DAT0, [PTR], #4
+ subs SIZE, SIZE, #4 @ C flag survives rest of macro
+ sub TMP0, DAT0, PATTERN, lsr #14
+ bic TMP0, TMP0, DAT0
+ ands TMP0, TMP0, PATTERN
+.endm
+
+.macro innerloop16 decrement, do_preload
+ ldmia PTR!, {DAT0,DAT1,DAT2,DAT3}
+ .ifnc "\do_preload",""
+ pld [PTR, #PRELOAD_DISTANCE*32]
+ .endif
+ .ifnc "\decrement",""
+ subs SIZE, SIZE, #\decrement @ C flag survives rest of macro
+ .endif
+ sub TMP0, DAT0, PATTERN, lsr #14
+ sub TMP1, DAT1, PATTERN, lsr #14
+ bic TMP0, TMP0, DAT0
+ bic TMP1, TMP1, DAT1
+ sub TMP2, DAT2, PATTERN, lsr #14
+ sub TMP3, DAT3, PATTERN, lsr #14
+ ands TMP0, TMP0, PATTERN
+ bic TMP2, TMP2, DAT2
+ it eq
+ andseq TMP1, TMP1, PATTERN
+ bic TMP3, TMP3, DAT3
+ itt eq
+ andseq TMP2, TMP2, PATTERN
+ andseq TMP3, TMP3, PATTERN
+.endm
+
+/* int ff_h264_find_start_code_candidate_armv6(const uint8_t *buf, int size) */
+function ff_h264_find_start_code_candidate_armv6, export=1
+ push {v1-v6,lr}
+ mov PTR, BUF
+ @ Ensure there are at least (PRELOAD_DISTANCE+2) complete cachelines to go
+ @ before using code that does preloads
+ cmp SIZE, #(PRELOAD_DISTANCE+3)*32 - 1
+ blo 60f
+
+ @ Get to word-alignment, 1 byte at a time
+ tst PTR, #3
+ beq 2f
+1: ldrb DAT0, [PTR], #1
+ sub SIZE, SIZE, #1
+ teq DAT0, #0
+ beq 90f
+ tst PTR, #3
+ bne 1b
+2: @ Get to 4-word alignment, 1 word at a time
+ ldr PATTERN, =0x80008000
+ setend be
+ tst PTR, #12
+ beq 4f
+3: innerloop4
+ bne 91f
+ tst PTR, #12
+ bne 3b
+4: @ Get to cacheline (8-word) alignment
+ tst PTR, #16
+ beq 5f
+ innerloop16 16
+ bne 93f
+5: @ Check complete cachelines, with preloading
+ @ We need to stop when there are still (PRELOAD_DISTANCE+1)
+ @ complete cachelines to go
+ sub SIZE, SIZE, #(PRELOAD_DISTANCE+2)*32
+6: innerloop16 , do_preload
+ bne 93f
+ innerloop16 32
+ bne 93f
+ bcs 6b
+ @ Preload trailing part-cacheline, if any
+ tst SIZE, #31
+ beq 7f
+ pld [PTR, #(PRELOAD_DISTANCE+1)*32]
+ @ Check remaining data without doing any more preloads. First
+ @ do in chunks of 4 words:
+7: adds SIZE, SIZE, #(PRELOAD_DISTANCE+2)*32 - 16
+ bmi 9f
+8: innerloop16 16
+ bne 93f
+ bcs 8b
+ @ Then in words:
+9: adds SIZE, SIZE, #16 - 4
+ bmi 11f
+10: innerloop4
+ bne 91f
+ bcs 10b
+11: setend le
+ @ Check second byte of final halfword
+ ldrb DAT0, [PTR, #-1]
+ teq DAT0, #0
+ beq 90f
+ @ Check any remaining bytes
+ tst SIZE, #3
+ beq 13f
+12: ldrb DAT0, [PTR], #1
+ sub SIZE, SIZE, #1
+ teq DAT0, #0
+ beq 90f
+ tst SIZE, #3
+ bne 12b
+ @ No candidate found
+13: sub RESULT, PTR, BUF
+ b 99f
+
+60: @ Small buffer - simply check by looping over bytes
+ subs SIZE, SIZE, #1
+ bcc 99f
+61: ldrb DAT0, [PTR], #1
+ subs SIZE, SIZE, #1
+ teq DAT0, #0
+ beq 90f
+ bcs 61b
+ @ No candidate found
+ sub RESULT, PTR, BUF
+ b 99f
+
+90: @ Found a candidate at the preceding byte
+ sub RESULT, PTR, BUF
+ sub RESULT, RESULT, #1
+ b 99f
+
+91: @ Found a candidate somewhere in the preceding 4 bytes
+ sub RESULT, PTR, BUF
+ sub RESULT, RESULT, #4
+ sub TMP0, DAT0, #0x20000
+ bics TMP0, TMP0, DAT0
+ itt pl
+ ldrbpl DAT0, [PTR, #-3]
+ addpl RESULT, RESULT, #2
+ bpl 92f
+ teq RESULT, #0
+ beq 98f @ don't look back a byte if found at first byte in buffer
+ ldrb DAT0, [PTR, #-5]
+92: teq DAT0, #0
+ it eq
+ subeq RESULT, RESULT, #1
+ b 98f
+
+93: @ Found a candidate somewhere in the preceding 16 bytes
+ sub RESULT, PTR, BUF
+ sub RESULT, RESULT, #16
+ teq TMP0, #0
+ beq 95f @ not in first 4 bytes
+ sub TMP0, DAT0, #0x20000
+ bics TMP0, TMP0, DAT0
+ itt pl
+ ldrbpl DAT0, [PTR, #-15]
+ addpl RESULT, RESULT, #2
+ bpl 94f
+ teq RESULT, #0
+ beq 98f @ don't look back a byte if found at first byte in buffer
+ ldrb DAT0, [PTR, #-17]
+94: teq DAT0, #0
+ it eq
+ subeq RESULT, RESULT, #1
+ b 98f
+95: add RESULT, RESULT, #4
+ teq TMP1, #0
+ beq 96f @ not in next 4 bytes
+ sub TMP1, DAT1, #0x20000
+ bics TMP1, TMP1, DAT1
+ itee mi
+ ldrbmi DAT0, [PTR, #-13]
+ ldrbpl DAT0, [PTR, #-11]
+ addpl RESULT, RESULT, #2
+ teq DAT0, #0
+ it eq
+ subeq RESULT, RESULT, #1
+ b 98f
+96: add RESULT, RESULT, #4
+ teq TMP2, #0
+ beq 97f @ not in next 4 bytes
+ sub TMP2, DAT2, #0x20000
+ bics TMP2, TMP2, DAT2
+ itee mi
+ ldrbmi DAT0, [PTR, #-9]
+ ldrbpl DAT0, [PTR, #-7]
+ addpl RESULT, RESULT, #2
+ teq DAT0, #0
+ it eq
+ subeq RESULT, RESULT, #1
+ b 98f
+97: add RESULT, RESULT, #4
+ sub TMP3, DAT3, #0x20000
+ bics TMP3, TMP3, DAT3
+ itee mi
+ ldrbmi DAT0, [PTR, #-5]
+ ldrbpl DAT0, [PTR, #-3]
+ addpl RESULT, RESULT, #2
+ teq DAT0, #0
+ it eq
+ subeq RESULT, RESULT, #1
+ @ drop through to 98f
+98: setend le
+99: pop {v1-v6,pc}
+.endfunc
+
+ .unreq RESULT
+ .unreq BUF
+ .unreq SIZE
+ .unreq PATTERN
+ .unreq PTR
+ .unreq DAT0
+ .unreq DAT1
+ .unreq DAT2
+ .unreq DAT3
+ .unreq TMP0
+ .unreq TMP1
+ .unreq TMP2
+ .unreq TMP3
diff --git a/libavcodec/arm/h264dsp_init_arm.c b/libavcodec/arm/h264dsp_init_arm.c
index cc4c688..c282c21 100644
--- a/libavcodec/arm/h264dsp_init_arm.c
+++ b/libavcodec/arm/h264dsp_init_arm.c
@@ -23,6 +23,8 @@
#include "libavcodec/dsputil.h"
#include "libavcodec/h264dsp.h"
+int ff_h264_find_start_code_candidate_armv6(const uint8_t *buf, int size);
+
void ff_h264_v_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha,
int beta, int8_t *tc0);
void ff_h264_h_loop_filter_luma_neon(uint8_t *pix, int stride, int alpha,
@@ -99,5 +101,7 @@ static void ff_h264dsp_init_neon(H264DSPContext *c, const int bit_depth, const i
void ff_h264dsp_init_arm(H264DSPContext *c, const int bit_depth, const int chroma_format_idc)
{
+ if (HAVE_ARMV6)
+ c->h264_find_start_code_candidate = ff_h264_find_start_code_candidate_armv6;
if (HAVE_NEON) ff_h264dsp_init_neon(c, bit_depth, chroma_format_idc);
}
--
1.8.1.6

View File

@ -1,122 +0,0 @@
From eff39646c73e74124621120bdcdccec4d62db61f Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michaelni@gmx.at>
Date: Thu, 23 Feb 2012 23:22:16 +0100
Subject: [PATCH 2/5] udp: Fix sign of error codes.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
---
libavformat/udp.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 9694ad2..309b18c 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -335,7 +335,7 @@ static void *circular_buffer_task( void *_URLContext)
int len;
if (ff_check_interrupt(&h->interrupt_callback)) {
- s->circular_buffer_error = EINTR;
+ s->circular_buffer_error = AVERROR(EINTR);
goto end;
}
@@ -347,7 +347,7 @@ static void *circular_buffer_task( void *_URLContext)
if (ret < 0) {
if (ff_neterrno() == AVERROR(EINTR))
continue;
- s->circular_buffer_error = EIO;
+ s->circular_buffer_error = AVERROR(EIO);
goto end;
}
@@ -361,14 +361,14 @@ static void *circular_buffer_task( void *_URLContext)
/* No Space left, error, what do we do now */
if(left < UDP_MAX_PKT_SIZE + 4) {
av_log(h, AV_LOG_ERROR, "circular_buffer: OVERRUN\n");
- s->circular_buffer_error = EIO;
+ s->circular_buffer_error = AVERROR(EIO);
goto end;
}
left = FFMIN(left, s->fifo->end - s->fifo->wptr);
len = recv(s->udp_fd, s->tmp+4, sizeof(s->tmp)-4, 0);
if (len < 0) {
if (ff_neterrno() != AVERROR(EAGAIN) && ff_neterrno() != AVERROR(EINTR)) {
- s->circular_buffer_error = EIO;
+ s->circular_buffer_error = AVERROR(EIO);
goto end;
}
continue;
--
1.8.1.5
From 13abee9310f7dd5982e9a0c5fde9b7f2a0ad9ce0 Mon Sep 17 00:00:00 2001
From: Nicolas George <nicolas.george@normalesup.org>
Date: Thu, 15 Mar 2012 12:19:37 +0100
Subject: [PATCH 3/5] udp: fix non-blocking and interrupt handling.
In non-blocking mode, lowest-level read protocols are
supposed block only for a short amount of time to let
retry_transfer_wrapper() check for interrupts.
Also, checking the interrupt_callback in the receiving thread is
wrong, as interrupt_callback is not guaranteed to be thread-safe
and the job is already done by retry_transfer_wrapper(). The error
code was also incorrect.
Bug reported by Andrey Utkin.
---
libavformat/udp.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 309b18c..ed1559d 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -334,11 +334,6 @@ static void *circular_buffer_task( void *_URLContext)
int ret;
int len;
- if (ff_check_interrupt(&h->interrupt_callback)) {
- s->circular_buffer_error = AVERROR(EINTR);
- goto end;
- }
-
FD_ZERO(&rfds);
FD_SET(s->udp_fd, &rfds);
tv.tv_sec = 1;
@@ -568,7 +563,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
{
UDPContext *s = h->priv_data;
int ret;
- int avail;
+ int avail, nonblock = h->flags & AVIO_FLAG_NONBLOCK;
#if HAVE_PTHREADS
if (s->fifo) {
@@ -592,12 +587,19 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
} else if(s->circular_buffer_error){
pthread_mutex_unlock(&s->mutex);
return s->circular_buffer_error;
- } else if(h->flags & AVIO_FLAG_NONBLOCK) {
+ } else if(nonblock) {
pthread_mutex_unlock(&s->mutex);
return AVERROR(EAGAIN);
}
else {
- pthread_cond_wait(&s->cond, &s->mutex);
+ /* FIXME: using the monotonic clock would be better,
+ but it does not exist on all supported platforms. */
+ int64_t t = av_gettime() + 100000;
+ struct timespec tv = { .tv_sec = t / 1000000,
+ .tv_nsec = (t % 1000000) * 1000 };
+ if (pthread_cond_timedwait(&s->cond, &s->mutex, &tv) < 0)
+ return AVERROR(errno == ETIMEDOUT ? EAGAIN : errno);
+ nonblock = 1;
}
} while( 1);
}
--
1.8.1.5