Commit 2c2fd3c2 authored by Thomas Petazzoni's avatar Thomas Petazzoni
Browse files

package/ffmpeg: Add Kodi patchset

In the past xbmc delivered its own ffmpeg source code with specific patches to
address bugs found during the use of xbmc. For Helix the ffmpeg source code was
removed, Helix uses a vanilla ffmpeg source tarball and applies this patchset
on top of it.

Downloaded from
https://github.com/xbmc/FFmpeg/compare/FFmpeg:release/2.5...release/2.5-xbmc.patch



[Thomas: use individual patches instead.]

Signed-off-by: default avatarBernd Kuhls <bernd.kuhls@t-online.de>
Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
parent 7863cfe0
Loading
Loading
Loading
Loading
+63 −0
Original line number Diff line number Diff line
From 74f1c9b43b191a9d6b494e90a4a11677fca33c13 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/13] 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.

Patch part of the XBMC patch set for ffmpeg, downloaded from
https://github.com/xbmc/FFmpeg/.

Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 libavcodec/dvdsubdec.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index 39604f3..a711e16 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -64,6 +64,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_crop_tab + 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;
@@ -697,6 +715,12 @@ static av_cold int dvdsub_init(AVCodecContext *avctx)
         parse_ifo_palette(ctx, ctx->ifo_str);
     if (ctx->palette_str)
         parse_palette(ctx, ctx->palette_str);
+
+    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:");
-- 
2.1.0
+42 −0
Original line number Diff line number Diff line
From fbd0b8b0239d3786b941adc89322b8e49e4c768e Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Mon, 12 Sep 2011 21:37:17 +0200
Subject: [PATCH 02/13] asf hacks

Patch part of the XBMC patch set for ffmpeg, downloaded from
https://github.com/xbmc/FFmpeg/.

Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 libavformat/asfdec.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 7f7bb4d..8911987 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -1549,9 +1549,20 @@ static int asf_read_seek(AVFormatContext *s, int stream_index,
     AVStream *st    = s->streams[stream_index];
     int ret = 0;
 
+    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 -1;
 
+    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);
-- 
2.1.0
+32 −0
Original line number Diff line number Diff line
From 54200b3e6009c6870e33c02c8bbcf023fcd92cac 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 03/13] if av_read_packet returns AVERROR_IO, we are done.
 ffmpeg's codecs might or might not handle returning any completed demuxed
 packets correctly

Patch part of the XBMC patch set for ffmpeg, downloaded from
https://github.com/xbmc/FFmpeg/.

Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 libavformat/utils.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index ae6347a..3e8af50 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1304,6 +1304,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;
             /* flush the parsers */
             for (i = 0; i < s->nb_streams; i++) {
                 st = s->streams[i];
-- 
2.1.0
+47 −0
Original line number Diff line number Diff line
From e9236f6fe3fae1ad4a3a2b6b63db493b083f0b21 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 04/13] added: Ticket #7187, TV Teletext support for DVB EBU
 Teletext streams

Patch part of the XBMC patch set for ffmpeg, downloaded from
https://github.com/xbmc/FFmpeg/.

Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 libavcodec/avcodec.h | 4 ++++
 libavformat/mpegts.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index dabae1b..dd6ef3f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -520,6 +520,10 @@ enum AVCodecID {
     AV_CODEC_ID_PJS        = MKBETAG('P','h','J','S'),
     AV_CODEC_ID_ASS        = MKBETAG('A','S','S',' '),  ///< ASS as defined in Matroska
 
+    /* data codecs */
+    AV_CODEC_ID_VBI_DATA= 0x17500,
+    AV_CODEC_ID_VBI_TELETEXT,
+
     /* other specific kind of codecs (generally used for attachments) */
     AV_CODEC_ID_FIRST_UNKNOWN = 0x18000,           ///< A dummy ID pointing at the start of various fake codecs.
     AV_CODEC_ID_TTF = 0x18000,
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 97da0a3..5dd28f1 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -729,6 +729,8 @@ static const StreamType DESC_types[] = {
     { 0x7b, AVMEDIA_TYPE_AUDIO,    AV_CODEC_ID_DTS          },
     { 0x56, AVMEDIA_TYPE_SUBTITLE, AV_CODEC_ID_DVB_TELETEXT },
     { 0x59, AVMEDIA_TYPE_SUBTITLE, AV_CODEC_ID_DVB_SUBTITLE }, /* subtitling descriptor */
+    { 0x45, AVMEDIA_TYPE_DATA,         AV_CODEC_ID_VBI_DATA }, /* VBI Data descriptor */
+    { 0x46, AVMEDIA_TYPE_DATA,     AV_CODEC_ID_VBI_TELETEXT }, /* VBI Teletext descriptor */
     { 0 },
 };
 
-- 
2.1.0
+46 −0
Original line number Diff line number Diff line
From 1f48ee2290e9041b0371eb9a9cb742e9568930a1 Mon Sep 17 00:00:00 2001
From: Joakim Plate <elupus@ecce.se>
Date: Sun, 18 Sep 2011 19:16:34 +0200
Subject: [PATCH 05/13] Don't accept mpegts PMT that isn't current

Patch part of the XBMC patch set for ffmpeg, downloaded from
https://github.com/xbmc/FFmpeg/.

Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 libavformat/mpegts.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 5dd28f1..9f85aed 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -572,6 +572,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;
@@ -643,6 +644,7 @@ static int parse_section_header(SectionHeader *h,
     val = get8(pp, p_end);
     if (val < 0)
         return val;
+    h->current = val & 0x1;
     h->version = (val >> 1) & 0x1f;
     val = get8(pp, p_end);
     if (val < 0)
@@ -1968,6 +1970,8 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
         return;
     if (ts->skip_changes)
         return;
+    if (!h->current)
+        return;
 
     ts->stream->ts_id = h->id;
 
-- 
2.1.0
Loading