Merge branch 'master' of code.vuplus.com:/opt/repository/openvuplus_3.0
[vuplus_openvuplus_3.0] / meta-bsp / recipes-multimedia / gstreamer / gstreamer1.0-plugin-dvbmediasink / dvbvideosink_vp9.patch
1 commit 4751cfaa5e3a15cf7154506154fd7c1e56c5a861
2 Author: oskwon <oskwon@dev3>
3 Date:   Wed Nov 22 14:38:46 2017 +0900
4
5     vp9
6
7 diff --git a/configure.ac b/configure.ac
8 index ff2abea..75c5e80 100644
9 --- a/configure.ac
10 +++ b/configure.ac
11 @@ -227,6 +227,13 @@ if test "$have_eac3" = "yes"; then
12         AC_DEFINE([HAVE_EAC3],[1],[Define to 1 for E-AC3 support])
13  fi
14  
15 +AC_ARG_WITH(vb9,
16 +       AS_HELP_STRING([--with-vb9],[support VP9 , yes or no]),
17 +       [have_vb9=$withval],[have_vb9=no])
18 +if test "$have_vb9" = "yes"; then
19 +       AC_DEFINE([HAVE_VB9],[1],[Define to 1 for VB9 support])
20 +fi
21 +
22  AC_ARG_WITH(dtsdownmix,
23         AS_HELP_STRING([--with-dtsdownmix],[build dts downmix element, yes or no]),
24         [have_dtsdownmix=$withval],[have_dtsdownmix=no])
25 diff --git a/gstdvbvideosink.c b/gstdvbvideosink.c
26 index 7a4f5b4..08ab3d5 100644
27 --- a/gstdvbvideosink.c
28 +++ b/gstdvbvideosink.c
29 @@ -239,6 +239,10 @@ GST_STATIC_PAD_TEMPLATE (
30         "video/x-wmv, "
31                 VIDEO_CAPS ", wmvversion = (int) 3; "
32  #endif
33 +#ifdef HAVE_VB9
34 +       "video/x-vp9, "
35 +               VIDEO_CAPS "; "
36 +#endif
37         "video/mpegts, systemstream=(boolean)true, "
38                 VIDEO_CAPS "; "
39         )
40 @@ -646,6 +650,7 @@ static int video_write(GstBaseSink *sink, GstDVBVideoSink *self, GstBuffer *buff
41                 }
42                 if (pfd[1].revents & POLLOUT)
43                 {
44 +                       int wr = 0;
45                         size_t queuestart, queueend;
46                         GstBuffer *queuebuffer;
47                         GST_OBJECT_LOCK(self);
48 @@ -659,7 +664,7 @@ static int video_write(GstBaseSink *sink, GstDVBVideoSink *self, GstBuffer *buff
49                                 gst_buffer_map(queuebuffer, &queuemap, GST_MAP_READ);
50                                 queuedata = queuemap.data;
51  #endif
52 -                               int wr = write(self->fd, queuedata + queuestart, queueend - queuestart);
53 +                               wr = write(self->fd, queuedata + queuestart, queueend - queuestart);
54  #if GST_VERSION_MAJOR >= 1
55                                 gst_buffer_unmap(queuebuffer, &queuemap);
56  #endif
57 @@ -691,7 +696,7 @@ static int video_write(GstBaseSink *sink, GstDVBVideoSink *self, GstBuffer *buff
58                                 continue;
59                         }
60                         GST_OBJECT_UNLOCK(self);
61 -                       int wr = write(self->fd, data + written, len - written);
62 +                       wr = write(self->fd, data + written, len - written);
63                         if (wr < 0)
64                         {
65                                 switch (errno)
66 @@ -984,6 +989,23 @@ static GstFlowReturn gst_dvbvideosink_render(GstBaseSink *sink, GstBuffer *buffe
67                                 }
68                         }
69                 }
70 +#ifdef HAVE_VB9
71 +               else if (self->codec_type == CT_VP9)
72 +               {
73 +                       uint32_t vp9_pts = (GST_TIME_AS_USECONDS(GST_BUFFER_PTS_IS_VALID(buffer) ? GST_BUFFER_PTS(buffer) : GST_BUFFER_DTS(buffer)) *45) / 1000;
74 +                       memcpy(&pes_header[9], &vp9_pts, sizeof(vp9_pts));
75 +
76 +                       uint32_t len = data_len + 4 + 6;
77 +                       memcpy(pes_header+pes_header_len, "BCMV", 4);
78 +                       pes_header_len += 4;
79 +                       pes_header[pes_header_len++] = (len & 0xFF000000) >> 24;
80 +                       pes_header[pes_header_len++] = (len & 0x00FF0000) >> 16;
81 +                       pes_header[pes_header_len++] = (len & 0x0000FF00) >> 8;
82 +                       pes_header[pes_header_len++] = (len & 0x000000FF) >> 0;
83 +                       pes_header[pes_header_len++] = 0;
84 +                       pes_header[pes_header_len++] = 0;
85 +               }
86 +#endif /* HAVE_VB9 */
87         }
88  
89  #ifdef PACK_UNPACKED_XVID_DIVX5_BITSTREAM
90 @@ -1701,7 +1723,14 @@ static gboolean gst_dvbvideosink_set_caps(GstBaseSink *basesink, GstCaps *caps)
91                         GST_INFO_OBJECT (self, "MIMETYPE video/x-wmv -> STREAMTYPE_VC1_SM");
92                 }
93         }
94 -
95 +#ifdef HAVE_VB9
96 +       else if (!strcmp (mimetype, "video/x-vp9"))
97 +       {
98 +               self->stream_type = STREAMTYPE_VB9;
99 +               self->codec_type = CT_VP9;
100 +               GST_INFO_OBJECT (self, "MIMETYPE video/x-vp9 -> VIDEO_SET_STREAMTYPE, STREAMTYPE_VB9");
101 +       }
102 +#endif
103         if (self->stream_type != STREAMTYPE_UNKNOWN)
104         {
105                 gint numerator, denominator;
106 diff --git a/gstdvbvideosink.h b/gstdvbvideosink.h
107 index d055d4a..3340840 100644
108 --- a/gstdvbvideosink.h
109 +++ b/gstdvbvideosink.h
110 @@ -65,7 +65,7 @@ typedef struct _GstDVBVideoSink               GstDVBVideoSink;
111  typedef struct _GstDVBVideoSinkClass   GstDVBVideoSinkClass;
112  typedef struct _GstDVBVideoSinkPrivate GstDVBVideoSinkPrivate;
113  
114 -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;
115 +typedef enum { CT_MPEG1, CT_MPEG2, CT_H264, CT_DIVX311, CT_DIVX4, CT_MPEG4_PART2, CT_VC1, CT_VC1_SM, CT_H265, CT_VP9 } t_codec_type;
116  typedef enum {
117         STREAMTYPE_UNKNOWN = -1,
118         STREAMTYPE_MPEG2 = 0,
119 @@ -75,6 +75,7 @@ typedef enum {
120         STREAMTYPE_MPEG4_Part2 = 4,
121         STREAMTYPE_VC1_SM = 5,
122         STREAMTYPE_MPEG1 = 6,
123 +       STREAMTYPE_VB9 = 9,
124         STREAMTYPE_XVID = 10,
125         STREAMTYPE_DIVX311 = 13,
126         STREAMTYPE_DIVX4 = 14,