[gstreamer1.0-plugin-dvbmediasink] update srcrev.
[vuplus_openvuplus_3.0] / meta-openvuplus / recipes-multimedia / gstreamer / gstreamer1.0-plugin-dvbmediasink / dvbmediasink_h265.patch
1 commit 88e0cef8dc07d4813634b65a78ae9d0fec023b7f
2 Author: hschang <chang@dev3>
3 Date:   Mon Jun 8 20:41:40 2015 +0900
4
5     support video/x-h265.
6
7 diff --git a/configure.ac b/configure.ac
8 index 4bf6908..ff2abea 100644
9 --- a/configure.ac
10 +++ b/configure.ac
11 @@ -130,6 +130,14 @@ if test "$have_mpeg4" = "yes"; then
12         AC_DEFINE([HAVE_MPEG4],[1],[Define to 1 for mpeg4 support])
13  fi
14  
15 +
16 +AC_ARG_WITH(h265,
17 +       AS_HELP_STRING([--with-h265],[support h265, yes or no]),
18 +       [have_h265=$withval],[have_h265=no])
19 +if test "$have_h265" = "yes"; then
20 +       AC_DEFINE([HAVE_H265],[1],[Define to 1 for h265 support])
21 +fi
22 +
23  AC_ARG_WITH(h264,
24         AS_HELP_STRING([--with-h264],[support h264, yes or no]),
25         [have_h264=$withval],[have_h264=yes])
26 diff --git a/gstdvbvideosink.c b/gstdvbvideosink.c
27 index fbebd11..80e7d0f 100644
28 --- a/gstdvbvideosink.c
29 +++ b/gstdvbvideosink.c
30 @@ -170,6 +170,8 @@ enum
31  
32  static guint gst_dvb_videosink_signals[LAST_SIGNAL] = { 0 };
33  
34 +#define HAVE_H265
35 +
36  static GstStaticPadTemplate sink_factory =
37  GST_STATIC_PAD_TEMPLATE (
38         "sink",
39 @@ -184,6 +186,10 @@ GST_STATIC_PAD_TEMPLATE (
40         "video/mpeg, "
41                 "mpegversion = (int) { 1, 2 }, "
42                 VIDEO_CAPS "; "
43 +#ifdef HAVE_H265
44 +               "video/x-h265, "
45 +                       VIDEO_CAPS "; "
46 +#endif
47  #ifdef HAVE_H264
48         "video/x-h264, "
49                 VIDEO_CAPS "; "
50 @@ -877,7 +883,7 @@ static GstFlowReturn gst_dvbvideosink_render(GstBaseSink *sink, GstBuffer *buffe
51                                         self->must_send_header = FALSE;
52                                 }
53                         }
54 -                       if (self->codec_type == CT_H264)
55 +                       if (self->codec_type == CT_H264 || self->codec_type == CT_H265)
56                         {
57                                 unsigned int pos = 0;
58                                 if (self->h264_nal_len_size >= 3)
59 @@ -1474,6 +1480,87 @@ static gboolean gst_dvbvideosink_set_caps(GstBaseSink *basesink, GstCaps *caps)
60                 }
61                 GST_INFO_OBJECT (self, "MIMETYPE video/x-h264 -> STREAMTYPE_MPEG4_H264");
62         }
63 +       else if (!strcmp (mimetype, "video/x-h265"))
64 +       {
65 +               const GValue *cd_data = gst_structure_get_value(structure, "codec_data");
66 +               self->stream_type = STREAMTYPE_MPEG4_H265;
67 +               self->codec_type = CT_H265;
68 +               if (cd_data)
69 +               {
70 +                       unsigned char tmp[2048];
71 +                       unsigned int tmp_len = 0;
72 +                       GstBuffer *codec_data = gst_value_get_buffer(cd_data);
73 +                       guint8 *data;
74 +                       gsize cd_len;
75 +                       unsigned int cd_pos = 0;
76 +#if GST_VERSION_MAJOR < 1
77 +                       data = GST_BUFFER_DATA(codec_data);
78 +                       cd_len = GST_BUFFER_SIZE(codec_data);
79 +#else
80 +                       GstMapInfo codecdatamap;
81 +                       gst_buffer_map(codec_data, &codecdatamap, GST_MAP_READ);
82 +                       data = codecdatamap.data;
83 +                       cd_len = codecdatamap.size;
84 +#endif
85 +                       GST_INFO_OBJECT (self, "H265 have codec data..!");
86 +
87 +                       if (cd_len > 3 && (data[0] || data[1] || data[2] > 1)) {
88 +                               if (cd_len > 22) {
89 +                                       int i;
90 +                                       if (data[0] != 0) {
91 +                                               GST_ELEMENT_WARNING (self, STREAM, DECODE, ("Unsupported extra data version %d, decoding may fail", data[0]), (NULL));
92 +                                       }
93 +                                       self->h264_nal_len_size = (data[21] & 3) + 1;
94 +                                       int num_param_sets = data[22];
95 +                                       int pos = 23;
96 +                                       for (i = 0; i < num_param_sets; i++) {
97 +                                               int j;
98 +                                               if (pos + 3 > cd_len) {
99 +                                                       GST_ELEMENT_ERROR (self, STREAM, DECODE, ("Buffer underrun in extra header (%d >= %ld)", pos + 3, cd_len), (NULL));
100 +                                                       break;
101 +                                               }
102 +                                               // ignore flags + NAL type (1 byte)
103 +                                               int nal_count = data[pos + 1] << 8 | data[pos + 2];
104 +                                               pos += 3;
105 +                                               for (j = 0; j < nal_count; j++) {
106 +                                                       if (pos + 2 > cd_len) {
107 +                                                               GST_ELEMENT_ERROR (self, STREAM, DECODE, ("Buffer underrun in extra nal header (%d >= %ld)", pos + 2, cd_len), (NULL));
108 +                                                               break;
109 +                                                       }
110 +                                                       int nal_size = data[pos] << 8 | data[pos + 1];
111 +                                                       pos += 2;
112 +                                                       if (pos + nal_size > cd_len) {
113 +                                                               GST_ELEMENT_ERROR (self, STREAM, DECODE, ("Buffer underrun in extra nal (%d >= %ld)", pos + 2 + nal_size, cd_len), (NULL));
114 +                                                               break;
115 +                                                       }
116 +                                                       memcpy(tmp+tmp_len, "\x00\x00\x00\x01", 4);
117 +                                                       tmp_len += 4;
118 +                                                       memcpy(tmp + tmp_len, data + pos, nal_size);
119 +                                                       tmp_len += nal_size;
120 +                                                       pos += nal_size;
121 +                                               }
122 +                                       }
123 +                               }
124 +                               GST_DEBUG ("Assuming packetized data (%d bytes length)", self->h264_nal_len_size);
125 +                               {
126 +                                       self->codec_data = gst_buffer_new_and_alloc(tmp_len);
127 +#if GST_VERSION_MAJOR < 1
128 +                                       memcpy(GST_BUFFER_DATA(self->codec_data), tmp, tmp_len);
129 +#else
130 +                                       gst_buffer_fill(self->codec_data, 0, tmp, tmp_len);
131 +#endif
132 +                               }
133 +                       }
134 +#if GST_VERSION_MAJOR >= 1
135 +                       gst_buffer_unmap(codec_data, &codecdatamap);
136 +#endif
137 +               }
138 +               else
139 +               {
140 +                       self->h264_nal_len_size = 0;
141 +               }
142 +               GST_INFO_OBJECT (self, "MIMETYPE video/x-h265 -> STREAMTYPE_MPEG4_H265");
143 +       }
144         else if (!strcmp (mimetype, "video/x-h263"))
145         {
146                 self->stream_type = STREAMTYPE_H263;
147 diff --git a/gstdvbvideosink.h b/gstdvbvideosink.h
148 index 8cf1dc2..8577f2d 100644
149 --- a/gstdvbvideosink.h
150 +++ b/gstdvbvideosink.h
151 @@ -65,7 +65,7 @@ typedef struct _GstDVBVideoSink               GstDVBVideoSink;
152  typedef struct _GstDVBVideoSinkClass   GstDVBVideoSinkClass;
153  typedef struct _GstDVBVideoSinkPrivate GstDVBVideoSinkPrivate;
154  
155 -typedef enum { CT_MPEG1, CT_MPEG2, CT_H264, CT_DIVX311, CT_DIVX4, CT_MPEG4_PART2, CT_VC1, CT_VC1_SM } t_codec_type;
156 +typedef enum { CT_MPEG1, CT_MPEG2, CT_H264, CT_DIVX311, CT_DIVX4, CT_MPEG4_PART2, CT_VC1, CT_VC1_SM, CT_H265 } t_codec_type;
157  typedef enum {
158         STREAMTYPE_UNKNOWN = -1,
159         STREAMTYPE_MPEG2 = 0,
160 @@ -78,7 +78,8 @@ typedef enum {
161         STREAMTYPE_XVID = 10,
162         STREAMTYPE_DIVX311 = 13,
163         STREAMTYPE_DIVX4 = 14,
164 -       STREAMTYPE_DIVX5 = 15
165 +       STREAMTYPE_DIVX5 = 15,
166 +       STREAMTYPE_MPEG4_H265 = 7
167  } t_stream_type;
168  
169  struct _GstDVBVideoSink