xbmc.patch 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. From f68c860bdc70e440f047ca60c8f9497a0e5a2122 Mon Sep 17 00:00:00 2001
  2. From: Joakim Plate <elupus@ecce.se>
  3. Date: Sun, 11 Sep 2011 19:04:51 +0200
  4. Subject: [PATCH 01/15] Support raw dvdsub palette as stored on normal dvd's
  5. This is how the palette is stored on dvd's. Currently
  6. only xbmc passes the palette information to libavcodec
  7. this way.
  8. ---
  9. libavcodec/dvdsubdec.c | 24 ++++++++++++++++++++++++
  10. 1 file changed, 24 insertions(+)
  11. diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
  12. index 39b0e25..a19086d 100644
  13. --- a/libavcodec/dvdsubdec.c
  14. +++ b/libavcodec/dvdsubdec.c
  15. @@ -61,6 +61,24 @@ static void yuv_a_to_rgba(const uint8_t *ycbcr, const uint8_t *alpha, uint32_t *
  16. }
  17. }
  18. +static void ayvu_to_argb(const uint8_t *ayvu, uint32_t *argb, int num_values)
  19. +{
  20. + uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
  21. + uint8_t r, g, b;
  22. + int i, y, cb, cr, a;
  23. + int r_add, g_add, b_add;
  24. +
  25. + for (i = num_values; i > 0; i--) {
  26. + a = *ayvu++;
  27. + y = *ayvu++;
  28. + cr = *ayvu++;
  29. + cb = *ayvu++;
  30. + YUV_TO_RGB1_CCIR(cb, cr);
  31. + YUV_TO_RGB2_CCIR(r, g, b, y);
  32. + *argb++ = (a << 24) | (r << 16) | (g << 8) | b;
  33. + }
  34. +}
  35. +
  36. static int decode_run_2bit(GetBitContext *gb, int *color)
  37. {
  38. unsigned int v, t;
  39. @@ -628,6 +646,12 @@ static av_cold int dvdsub_init(AVCodecContext *avctx)
  40. if (ctx->palette_str)
  41. parse_palette(ctx, ctx->palette_str);
  42. +
  43. + if (!ctx->has_palette && avctx->extradata_size == 64) {
  44. + ayvu_to_argb((uint8_t*)avctx->extradata, ctx->palette, 16);
  45. + ctx->has_palette = 1;
  46. + }
  47. +
  48. if (ctx->has_palette) {
  49. int i;
  50. av_log(avctx, AV_LOG_DEBUG, "palette:");
  51. --
  52. 1.9.3
  53. From d53ff2a91f95b2b6ef3974921228e90a4a765af6 Mon Sep 17 00:00:00 2001
  54. From: Joakim Plate <elupus@ecce.se>
  55. Date: Sat, 22 Oct 2011 18:33:45 +0200
  56. Subject: [PATCH 02/15] Check return value of avio_seek and avoid modifying
  57. state if it fails
  58. The code still modifies state if the timestamp is not found. Not
  59. sure exactly how to avoid that.
  60. ---
  61. libavformat/matroskadec.c | 23 ++++++++++++++---------
  62. 1 file changed, 14 insertions(+), 9 deletions(-)
  63. diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
  64. index ec43526..66d5e8e 100644
  65. --- a/libavformat/matroskadec.c
  66. +++ b/libavformat/matroskadec.c
  67. @@ -2992,8 +2992,8 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
  68. timestamp = FFMAX(timestamp, st->index_entries[0].timestamp);
  69. if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
  70. - avio_seek(s->pb, st->index_entries[st->nb_index_entries - 1].pos,
  71. - SEEK_SET);
  72. + if (avio_seek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET) < 0)
  73. + return -1;
  74. matroska->current_id = 0;
  75. while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
  76. matroska_clear_queue(matroska);
  77. @@ -3002,16 +3002,11 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
  78. }
  79. }
  80. - matroska_clear_queue(matroska);
  81. if (index < 0 || (matroska->cues_parsing_deferred < 0 && index == st->nb_index_entries - 1))
  82. goto err;
  83. index_min = index;
  84. for (i = 0; i < matroska->tracks.nb_elem; i++) {
  85. - tracks[i].audio.pkt_cnt = 0;
  86. - tracks[i].audio.sub_packet_cnt = 0;
  87. - tracks[i].audio.buf_timecode = AV_NOPTS_VALUE;
  88. - tracks[i].end_timecode = 0;
  89. if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE &&
  90. tracks[i].stream->discard != AVDISCARD_ALL) {
  91. index_sub = av_index_search_timestamp(
  92. @@ -3025,8 +3020,18 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
  93. }
  94. }
  95. - avio_seek(s->pb, st->index_entries[index_min].pos, SEEK_SET);
  96. - matroska->current_id = 0;
  97. + if (avio_seek(s->pb, st->index_entries[index_min].pos, SEEK_SET) < 0)
  98. + return -1;
  99. +
  100. + matroska_clear_queue(matroska);
  101. + for (i=0; i < matroska->tracks.nb_elem; i++) {
  102. + tracks[i].audio.pkt_cnt = 0;
  103. + tracks[i].audio.sub_packet_cnt = 0;
  104. + tracks[i].audio.buf_timecode = AV_NOPTS_VALUE;
  105. + tracks[i].end_timecode = 0;
  106. + }
  107. + matroska->current_id = 0;
  108. +
  109. if (flags & AVSEEK_FLAG_ANY) {
  110. st->skip_to_keyframe = 0;
  111. matroska->skip_to_timecode = timestamp;
  112. --
  113. 1.9.3
  114. From d8c6b50095900bbc4f40dfb3c2d321a35361820a Mon Sep 17 00:00:00 2001
  115. From: Joakim Plate <elupus@ecce.se>
  116. Date: Mon, 12 Sep 2011 21:37:17 +0200
  117. Subject: [PATCH 03/15] asf hacks
  118. ---
  119. libavformat/asfdec.c | 11 +++++++++++
  120. 1 file changed, 11 insertions(+)
  121. diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
  122. index 978b956..30f099d 100644
  123. --- a/libavformat/asfdec.c
  124. +++ b/libavformat/asfdec.c
  125. @@ -1546,9 +1546,20 @@ static int asf_read_seek(AVFormatContext *s, int stream_index,
  126. AVStream *st = s->streams[stream_index];
  127. int ret = 0;
  128. + if (pts == 0) {
  129. + // this is a hack since av_gen_search searches the entire file in this case
  130. + av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", s->data_offset);
  131. + if (avio_seek(s->pb, s->data_offset, SEEK_SET) < 0)
  132. + return -1;
  133. + return 0;
  134. + }
  135. +
  136. if (s->packet_size <= 0)
  137. return -1;
  138. + if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO)
  139. + return -1;
  140. +
  141. /* Try using the protocol's read_seek if available */
  142. if (s->pb) {
  143. int ret = avio_seek_time(s->pb, stream_index, pts, flags);
  144. --
  145. 1.9.3
  146. From bb32180f7e9fe2ff89888c26731dc043844b49e2 Mon Sep 17 00:00:00 2001
  147. From: Cory Fields <theuni-nospam-@xbmc.org>
  148. Date: Mon, 28 Jun 2010 01:55:31 -0400
  149. Subject: [PATCH 04/15] if av_read_packet returns AVERROR_IO, we are done.
  150. ffmpeg's codecs might or might not handle returning any completed demuxed
  151. packets correctly
  152. ---
  153. libavformat/utils.c | 2 ++
  154. 1 file changed, 2 insertions(+)
  155. diff --git a/libavformat/utils.c b/libavformat/utils.c
  156. index e095d60..9fa0bb0 100644
  157. --- a/libavformat/utils.c
  158. +++ b/libavformat/utils.c
  159. @@ -1460,6 +1460,8 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
  160. if (ret < 0) {
  161. if (ret == AVERROR(EAGAIN))
  162. return ret;
  163. + if (ret == AVERROR(EIO))
  164. + return ret;
  165. /* flush the parsers */
  166. for (i = 0; i < s->nb_streams; i++) {
  167. st = s->streams[i];
  168. --
  169. 1.9.3
  170. From aae4de70cac340ed7e1b8db34125216c1e13cb00 Mon Sep 17 00:00:00 2001
  171. From: Cory Fields <theuni-nospam-@xbmc.org>
  172. Date: Mon, 28 Jun 2010 02:10:50 -0400
  173. Subject: [PATCH 05/15] added: Ticket #7187, TV Teletext support for DVB EBU
  174. Teletext streams
  175. ---
  176. libavcodec/avcodec.h | 4 ++++
  177. libavformat/mpegts.c | 2 ++
  178. 2 files changed, 6 insertions(+)
  179. diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
  180. index 93ba4d0..f3de33a 100644
  181. --- a/libavcodec/avcodec.h
  182. +++ b/libavcodec/avcodec.h
  183. @@ -523,6 +523,10 @@ enum AVCodecID {
  184. AV_CODEC_ID_PJS = MKBETAG('P','h','J','S'),
  185. AV_CODEC_ID_ASS = MKBETAG('A','S','S',' '), ///< ASS as defined in Matroska
  186. + /* data codecs */
  187. + AV_CODEC_ID_VBI_DATA= 0x17500,
  188. + AV_CODEC_ID_VBI_TELETEXT,
  189. +
  190. /* other specific kind of codecs (generally used for attachments) */
  191. AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
  192. AV_CODEC_ID_TTF = 0x18000,
  193. diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
  194. index 7114088..e55193b 100644
  195. --- a/libavformat/mpegts.c
  196. +++ b/libavformat/mpegts.c
  197. @@ -708,6 +708,8 @@ static const StreamType DESC_types[] = {
  198. { 0x7b, AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_DTS },
  199. { 0x56, AVMEDIA_TYPE_SUBTITLE, AV_CODEC_ID_DVB_TELETEXT },
  200. { 0x59, AVMEDIA_TYPE_SUBTITLE, AV_CODEC_ID_DVB_SUBTITLE }, /* subtitling descriptor */
  201. + { 0x45, AVMEDIA_TYPE_DATA, AV_CODEC_ID_VBI_DATA }, /* VBI Data descriptor */
  202. + { 0x46, AVMEDIA_TYPE_DATA, AV_CODEC_ID_VBI_TELETEXT }, /* VBI Teletext descriptor */
  203. { 0 },
  204. };
  205. --
  206. 1.9.3
  207. From e71d4c1755bd4e23fe9b65fb6128a8b41cecfdb1 Mon Sep 17 00:00:00 2001
  208. From: Joakim Plate <elupus@ecce.se>
  209. Date: Sun, 18 Sep 2011 19:16:34 +0200
  210. Subject: [PATCH 06/15] Don't accept mpegts PMT that isn't current
  211. ---
  212. libavformat/mpegts.c | 4 ++++
  213. 1 file changed, 4 insertions(+)
  214. diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
  215. index e55193b..9ec6220 100644
  216. --- a/libavformat/mpegts.c
  217. +++ b/libavformat/mpegts.c
  218. @@ -552,6 +552,7 @@ typedef struct SectionHeader {
  219. uint8_t tid;
  220. uint16_t id;
  221. uint8_t version;
  222. + uint8_t current;
  223. uint8_t sec_num;
  224. uint8_t last_sec_num;
  225. } SectionHeader;
  226. @@ -623,6 +624,7 @@ static int parse_section_header(SectionHeader *h,
  227. val = get8(pp, p_end);
  228. if (val < 0)
  229. return val;
  230. + h->current = val & 0x1;
  231. h->version = (val >> 1) & 0x1f;
  232. val = get8(pp, p_end);
  233. if (val < 0)
  234. @@ -1891,6 +1893,8 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
  235. return;
  236. if (ts->skip_changes)
  237. return;
  238. + if (!h->current)
  239. + return;
  240. ts->stream->ts_id = h->id;
  241. --
  242. 1.9.3
  243. From 473091d11f4e3a0c1820054368a76074a0e239cb Mon Sep 17 00:00:00 2001
  244. From: Joakim Plate <elupus@ecce.se>
  245. Date: Sun, 18 Sep 2011 19:17:23 +0200
  246. Subject: [PATCH 07/15] Don't reparse PMT unless it's version has changed
  247. ---
  248. libavformat/mpegts.c | 6 ++++++
  249. 1 file changed, 6 insertions(+)
  250. diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
  251. index 9ec6220..ab03372 100644
  252. --- a/libavformat/mpegts.c
  253. +++ b/libavformat/mpegts.c
  254. @@ -87,6 +87,7 @@ struct MpegTSFilter {
  255. int es_id;
  256. int last_cc; /* last cc code (-1 if first packet) */
  257. int64_t last_pcr;
  258. + int last_version; /* last version of data on this pid */
  259. enum MpegTSFilterType type;
  260. union {
  261. MpegTSPESFilter pes_filter;
  262. @@ -432,6 +433,7 @@ static MpegTSFilter *mpegts_open_filter(MpegTSContext *ts, unsigned int pid,
  263. filter->es_id = -1;
  264. filter->last_cc = -1;
  265. filter->last_pcr= -1;
  266. + filter->last_version = -1;
  267. return filter;
  268. }
  269. @@ -1895,6 +1897,10 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
  270. return;
  271. if (!h->current)
  272. return;
  273. + if (h->version == filter->last_version)
  274. + return;
  275. + filter->last_version = h->version;
  276. + av_dlog(ts->stream, "version=%d\n", filter->last_version);
  277. ts->stream->ts_id = h->id;
  278. --
  279. 1.9.3
  280. From aa357f84bcdb105910478aee74d5b675d65114bd Mon Sep 17 00:00:00 2001
  281. From: Cory Fields <theuni-nospam-@xbmc.org>
  282. Date: Fri, 9 Jul 2010 16:43:31 -0400
  283. Subject: [PATCH 08/15] Read PID timestamps as well as PCR timestamps to find
  284. location in mpegts stream
  285. ---
  286. libavformat/mpegts.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
  287. 1 file changed, 46 insertions(+), 2 deletions(-)
  288. diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
  289. index ab03372..9962ccf 100644
  290. --- a/libavformat/mpegts.c
  291. +++ b/libavformat/mpegts.c
  292. @@ -2375,6 +2375,44 @@ static void seek_back(AVFormatContext *s, AVIOContext *pb, int64_t pos) {
  293. av_log(s, pb->seekable ? AV_LOG_ERROR : AV_LOG_INFO, "Unable to seek back to the start\n");
  294. }
  295. +static int parse_timestamp(int64_t *ts, const uint8_t *buf)
  296. +{
  297. + int afc, flags;
  298. + const uint8_t *p;
  299. +
  300. + if(!(buf[1] & 0x40)) /* must be a start packet */
  301. + return -1;
  302. +
  303. + afc = (buf[3] >> 4) & 3;
  304. + p = buf + 4;
  305. + if (afc == 0 || afc == 2) /* invalid or only adaption field */
  306. + return -1;
  307. + if (afc == 3)
  308. + p += p[0] + 1;
  309. + if (p >= buf + TS_PACKET_SIZE)
  310. + return -1;
  311. +
  312. + if (p[0] != 0x00 || p[1] != 0x00 || p[2] != 0x01) /* packet_start_code_prefix */
  313. + return -1;
  314. +
  315. + flags = p[3] | 0x100; /* stream type */
  316. + if (!((flags >= 0x1c0 && flags <= 0x1df) ||
  317. + (flags >= 0x1e0 && flags <= 0x1ef) ||
  318. + (flags == 0x1bd) || (flags == 0x1fd)))
  319. + return -1;
  320. +
  321. + flags = p[7];
  322. + if ((flags & 0xc0) == 0x80) {
  323. + *ts = ff_parse_pes_pts(p+9);
  324. + return 0;
  325. + } else if ((flags & 0xc0) == 0xc0) {
  326. + *ts = ff_parse_pes_pts(p+9+5);
  327. + return 0;
  328. + }
  329. + return -1;
  330. +}
  331. +
  332. +
  333. static int mpegts_read_header(AVFormatContext *s)
  334. {
  335. MpegTSContext *ts = s->priv_data;
  336. @@ -2574,6 +2612,7 @@ static av_unused int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
  337. uint8_t buf[TS_PACKET_SIZE];
  338. int pcr_l, pcr_pid =
  339. ((PESContext *)s->streams[stream_index]->priv_data)->pcr_pid;
  340. + int pid = ((PESContext*)s->streams[stream_index]->priv_data)->pid;
  341. int pos47 = ts->pos47_full % ts->raw_packet_size;
  342. pos =
  343. ((*ppos + ts->raw_packet_size - 1 - pos47) / ts->raw_packet_size) *
  344. @@ -2595,6 +2634,11 @@ static av_unused int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
  345. *ppos = pos;
  346. return timestamp;
  347. }
  348. + if ((pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pid) &&
  349. + parse_timestamp(&timestamp, buf) == 0) {
  350. + *ppos = pos;
  351. + return timestamp;
  352. + }
  353. pos += ts->raw_packet_size;
  354. }
  355. @@ -2694,7 +2738,7 @@ AVInputFormat ff_mpegts_demuxer = {
  356. .read_header = mpegts_read_header,
  357. .read_packet = mpegts_read_packet,
  358. .read_close = mpegts_read_close,
  359. - .read_timestamp = mpegts_get_dts,
  360. + .read_timestamp = mpegts_get_pcr,
  361. .flags = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
  362. .priv_class = &mpegts_class,
  363. };
  364. @@ -2706,7 +2750,7 @@ AVInputFormat ff_mpegtsraw_demuxer = {
  365. .read_header = mpegts_read_header,
  366. .read_packet = mpegts_raw_read_packet,
  367. .read_close = mpegts_read_close,
  368. - .read_timestamp = mpegts_get_dts,
  369. + .read_timestamp = mpegts_get_pcr,
  370. .flags = AVFMT_SHOW_IDS | AVFMT_TS_DISCONT,
  371. .priv_class = &mpegtsraw_class,
  372. };
  373. --
  374. 1.9.3
  375. From 8deda04d599f1e248cba4d175257dea469feb719 Mon Sep 17 00:00:00 2001
  376. From: Joakim Plate <elupus@ecce.se>
  377. Date: Sat, 22 Oct 2011 19:01:38 +0200
  378. Subject: [PATCH 09/15] Get stream durations using read_timestamp
  379. ---
  380. libavformat/utils.c | 39 +++++++++++++++++++++++++++++++++++++++
  381. 1 file changed, 39 insertions(+)
  382. diff --git a/libavformat/utils.c b/libavformat/utils.c
  383. index 9fa0bb0..cbeaa9c 100644
  384. --- a/libavformat/utils.c
  385. +++ b/libavformat/utils.c
  386. @@ -2480,6 +2480,41 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic)
  387. #define DURATION_MAX_READ_SIZE 250000LL
  388. #define DURATION_MAX_RETRY 4
  389. +static void av_estimate_timings_from_pts2(AVFormatContext *ic, int64_t old_offset)
  390. +{
  391. + AVStream *st;
  392. + int i, step= 1024;
  393. + int64_t ts, pos;
  394. +
  395. + for(i=0;i<ic->nb_streams;i++) {
  396. + st = ic->streams[i];
  397. +
  398. + pos = 0;
  399. + ts = ic->iformat->read_timestamp(ic, i, &pos, DURATION_MAX_READ_SIZE);
  400. + if (ts == AV_NOPTS_VALUE)
  401. + continue;
  402. + if (st->start_time > ts || st->start_time == AV_NOPTS_VALUE)
  403. + st->start_time = ts;
  404. +
  405. + pos = avio_size(ic->pb) - 1;
  406. + do {
  407. + pos -= step;
  408. + ts = ic->iformat->read_timestamp(ic, i, &pos, pos + step);
  409. + step += step;
  410. + } while (ts == AV_NOPTS_VALUE && pos >= step && step < DURATION_MAX_READ_SIZE);
  411. +
  412. + if (ts == AV_NOPTS_VALUE)
  413. + continue;
  414. +
  415. + if (st->duration < ts - st->start_time || st->duration == AV_NOPTS_VALUE)
  416. + st->duration = ts - st->start_time;
  417. + }
  418. +
  419. + fill_all_stream_timings(ic);
  420. +
  421. + avio_seek(ic->pb, old_offset, SEEK_SET);
  422. +}
  423. +
  424. /* only usable for MPEG-PS streams */
  425. static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
  426. {
  427. @@ -2630,6 +2665,10 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
  428. * the components */
  429. fill_all_stream_timings(ic);
  430. ic->duration_estimation_method = AVFMT_DURATION_FROM_STREAM;
  431. + } else if (ic->iformat->read_timestamp &&
  432. + file_size && ic->pb->seekable) {
  433. + /* get accurate estimate from the PTSes */
  434. + av_estimate_timings_from_pts2(ic, old_offset);
  435. } else {
  436. /* less precise: use bitrate info */
  437. estimate_timings_from_bit_rate(ic);
  438. --
  439. 1.9.3
  440. From 77caa1aab9b838a0085e2f4133d0e27eb6588f4b Mon Sep 17 00:00:00 2001
  441. From: Joakim Plate <elupus@ecce.se>
  442. Date: Wed, 8 Dec 2010 14:03:43 +0000
  443. Subject: [PATCH 10/15] changed: allow 4 second skew between streams in mov
  444. before attempting to seek
  445. ---
  446. libavformat/mov.c | 4 ++--
  447. 1 file changed, 2 insertions(+), 2 deletions(-)
  448. diff --git a/libavformat/mov.c b/libavformat/mov.c
  449. index 9b4832f..41be8b7 100644
  450. --- a/libavformat/mov.c
  451. +++ b/libavformat/mov.c
  452. @@ -3673,8 +3673,8 @@ static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st)
  453. if (!sample || (!s->pb->seekable && current_sample->pos < sample->pos) ||
  454. (s->pb->seekable &&
  455. ((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb &&
  456. - ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) ||
  457. - (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))))) {
  458. + ((FFABS(best_dts - dts) <= 4*AV_TIME_BASE && current_sample->pos < sample->pos) ||
  459. + (FFABS(best_dts - dts) > 4*AV_TIME_BASE && dts < best_dts)))))) {
  460. sample = current_sample;
  461. best_dts = dts;
  462. *st = avst;
  463. --
  464. 1.9.3
  465. From c3d69fb6f71a674310fefb17aebab01a6744881c Mon Sep 17 00:00:00 2001
  466. From: Joakim Plate <elupus@ecce.se>
  467. Date: Fri, 26 Nov 2010 20:56:48 +0000
  468. Subject: [PATCH 11/15] fixed: memleak in mpegts demuxer on some malformed (??)
  469. mpegts files with too large pes packets
  470. at-visions sample file brokenStream.mpg
  471. ---
  472. libavformat/mpegts.c | 6 ++++++
  473. 1 file changed, 6 insertions(+)
  474. diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
  475. index 9962ccf..66ea11c 100644
  476. --- a/libavformat/mpegts.c
  477. +++ b/libavformat/mpegts.c
  478. @@ -811,6 +811,10 @@ static void reset_pes_packet_state(PESContext *pes)
  479. static void new_pes_packet(PESContext *pes, AVPacket *pkt)
  480. {
  481. + if(pkt->data) {
  482. + av_log(pes->stream, AV_LOG_ERROR, "ignoring previously allocated packet on stream %d\n", pkt->stream_index);
  483. + av_free_packet(pkt);
  484. + }
  485. av_init_packet(pkt);
  486. pkt->buf = pes->buffer;
  487. @@ -2565,6 +2569,8 @@ static int mpegts_read_packet(AVFormatContext *s, AVPacket *pkt)
  488. pkt->size = -1;
  489. ts->pkt = pkt;
  490. + ts->pkt->data = NULL;
  491. +
  492. ret = handle_packets(ts, 0);
  493. if (ret < 0) {
  494. av_free_packet(ts->pkt);
  495. --
  496. 1.9.3
  497. From e621e2b83b43a5fade298251094458451eecad41 Mon Sep 17 00:00:00 2001
  498. From: Joakim Plate <elupus@ecce.se>
  499. Date: Mon, 28 Jun 2010 21:26:54 +0000
  500. Subject: [PATCH 12/15] Speed up mpegts av_find_stream_info
  501. ---
  502. libavformat/mpegts.c | 2 +-
  503. 1 file changed, 1 insertion(+), 1 deletion(-)
  504. diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
  505. index 66ea11c..5811d26 100644
  506. --- a/libavformat/mpegts.c
  507. +++ b/libavformat/mpegts.c
  508. @@ -969,7 +969,7 @@ static int mpegts_push_data(MpegTSFilter *filter,
  509. goto skip;
  510. /* stream not present in PMT */
  511. - if (!pes->st) {
  512. + if (ts->auto_guess && !pes->st) {
  513. if (ts->skip_changes)
  514. goto skip;
  515. --
  516. 1.9.3
  517. From 07a31ecbe3493cbc1d1a5b6dee7784257a70ca17 Mon Sep 17 00:00:00 2001
  518. From: marc <mhocking@ubuntu-desktop.(none)>
  519. Date: Mon, 18 Feb 2013 17:18:18 +0000
  520. Subject: [PATCH 13/15] dxva-h264 Fix dxva playback of streams that don't start
  521. with an I-Frame.
  522. ---
  523. libavcodec/dxva2_h264.c | 8 ++++++++
  524. libavcodec/h264.c | 1 +
  525. libavcodec/h264.h | 2 ++
  526. libavcodec/h264_slice.c | 1 +
  527. 4 files changed, 12 insertions(+)
  528. diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
  529. index 1174188..263a272 100644
  530. --- a/libavcodec/dxva2_h264.c
  531. +++ b/libavcodec/dxva2_h264.c
  532. @@ -448,6 +448,14 @@ static int dxva2_h264_end_frame(AVCodecContext *avctx)
  533. if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
  534. return -1;
  535. +
  536. + // Wait for an I-frame before start decoding. Workaround for ATI UVD and UVD+ GPUs
  537. + if (!h->got_first_iframe) {
  538. + if (!(ctx_pic->pp.wBitFields & (1 << 15)))
  539. + return -1;
  540. + h->got_first_iframe = 1;
  541. + }
  542. +
  543. ret = ff_dxva2_common_end_frame(avctx, &h->cur_pic_ptr->f,
  544. &ctx_pic->pp, sizeof(ctx_pic->pp),
  545. &ctx_pic->qm, sizeof(ctx_pic->qm),
  546. diff --git a/libavcodec/h264.c b/libavcodec/h264.c
  547. index 1d91987..8b7b026 100644
  548. --- a/libavcodec/h264.c
  549. +++ b/libavcodec/h264.c
  550. @@ -1085,6 +1085,7 @@ void ff_h264_flush_change(H264Context *h)
  551. h->list_count = 0;
  552. h->current_slice = 0;
  553. h->mmco_reset = 1;
  554. + h->got_first_iframe = 0;
  555. }
  556. /* forget old pics after a seek */
  557. diff --git a/libavcodec/h264.h b/libavcodec/h264.h
  558. index 228558b..5e92043 100644
  559. --- a/libavcodec/h264.h
  560. +++ b/libavcodec/h264.h
  561. @@ -740,6 +740,8 @@ typedef struct H264Context {
  562. int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag
  563. int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag
  564. + int got_first_iframe;
  565. +
  566. // Timestamp stuff
  567. int sei_buffering_period_present; ///< Buffering period SEI flag
  568. int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
  569. diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
  570. index ded26f8..e20f2c8 100644
  571. --- a/libavcodec/h264_slice.c
  572. +++ b/libavcodec/h264_slice.c
  573. @@ -1166,6 +1166,7 @@ static int h264_slice_header_init(H264Context *h, int reinit)
  574. ff_h264_free_tables(h, 0);
  575. h->first_field = 0;
  576. h->prev_interlaced_frame = 1;
  577. + h->got_first_iframe = 0;
  578. init_scan_tables(h);
  579. ret = ff_h264_alloc_tables(h);
  580. --
  581. 1.9.3
  582. From 67247a541dc1dfb547d35eb326ecf26b6c10b4d3 Mon Sep 17 00:00:00 2001
  583. From: elupus <elupus@xbmc.org>
  584. Date: Tue, 1 Nov 2011 20:18:35 +0100
  585. Subject: [PATCH 14/15] add public version of ff_read_frame_flush
  586. We need this since we sometimes seek on the
  587. input stream behind ffmpeg's back. After this
  588. all data need to be flushed completely.
  589. ---
  590. libavformat/avformat.h | 5 +++++
  591. libavformat/utils.c | 5 +++++
  592. 2 files changed, 10 insertions(+)
  593. diff --git a/libavformat/avformat.h b/libavformat/avformat.h
  594. index a9abfbd..ff19215 100644
  595. --- a/libavformat/avformat.h
  596. +++ b/libavformat/avformat.h
  597. @@ -2074,6 +2074,11 @@ int av_read_packet(AVFormatContext *s, AVPacket *pkt);
  598. int av_read_frame(AVFormatContext *s, AVPacket *pkt);
  599. /**
  600. + * Clear out any buffered data in context
  601. + */
  602. +void av_read_frame_flush(AVFormatContext *s);
  603. +
  604. +/**
  605. * Seek to the keyframe at timestamp.
  606. * 'timestamp' in 'stream_index'.
  607. *
  608. diff --git a/libavformat/utils.c b/libavformat/utils.c
  609. index cbeaa9c..185706f 100644
  610. --- a/libavformat/utils.c
  611. +++ b/libavformat/utils.c
  612. @@ -1748,6 +1748,11 @@ void ff_read_frame_flush(AVFormatContext *s)
  613. }
  614. }
  615. +void av_read_frame_flush(AVFormatContext *s)
  616. +{
  617. + ff_read_frame_flush(s);
  618. +}
  619. +
  620. void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp)
  621. {
  622. int i;
  623. --
  624. 1.9.3
  625. From d028c907004e8a3c0f5161ce595331e4cc57c86c Mon Sep 17 00:00:00 2001
  626. From: Memphiz <memphis@machzwo.de>
  627. Date: Mon, 12 May 2014 18:27:01 +0200
  628. Subject: [PATCH 15/15] fix --disable-ffplay should disable any needs to check
  629. or add compile/link flags otherwise SDL gets spewed all over pkg-config files
  630. and generally causes a mess
  631. ---
  632. configure | 32 +++++++++++++++++---------------
  633. 1 file changed, 17 insertions(+), 15 deletions(-)
  634. diff --git a/configure b/configure
  635. index 4ed43a0..4520e8c 100755
  636. --- a/configure
  637. +++ b/configure
  638. @@ -4827,22 +4827,24 @@ if enabled libdc1394; then
  639. die "ERROR: No version of libdc1394 found "
  640. fi
  641. -SDL_CONFIG="${cross_prefix}sdl-config"
  642. -if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
  643. - check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
  644. - check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
  645. - enable sdl
  646. -else
  647. - if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
  648. - sdl_cflags=$("${SDL_CONFIG}" --cflags)
  649. - sdl_libs=$("${SDL_CONFIG}" --libs)
  650. - check_func_headers SDL_version.h SDL_Linked_Version $sdl_cflags $sdl_libs &&
  651. - check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
  652. - check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
  653. - enable sdl
  654. - fi
  655. +if enabled ffplay; then
  656. + SDL_CONFIG="${cross_prefix}sdl-config"
  657. + if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
  658. + check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
  659. + check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
  660. + enable sdl
  661. + else
  662. + if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
  663. + sdl_cflags=$("${SDL_CONFIG}" --cflags)
  664. + sdl_libs=$("${SDL_CONFIG}" --libs)
  665. + check_func_headers SDL_version.h SDL_Linked_Version $sdl_cflags $sdl_libs &&
  666. + check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
  667. + check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
  668. + enable sdl
  669. + fi
  670. + fi
  671. + enabled sdl && add_cflags $sdl_cflags && add_extralibs $sdl_libs
  672. fi
  673. -enabled sdl && add_cflags $sdl_cflags && add_extralibs $sdl_libs
  674. texi2html --help 2> /dev/null | grep -q 'init-file' && enable texi2html || disable texi2html
  675. makeinfo --version > /dev/null 2>&1 && enable makeinfo || disable makeinfo
  676. --
  677. 1.9.3