]> git.pld-linux.org Git - packages/ffmpeg.git/blob - ffmpeg-utvideo.patch
947bca30542dbb61150a50b118d9b9def3c17847
[packages/ffmpeg.git] / ffmpeg-utvideo.patch
1 --- ffmpeg-2.8.5/libavcodec/libutvideoenc.cpp.orig      2016-01-17 15:47:01.790581181 +0100
2 +++ ffmpeg-2.8.5/libavcodec/libutvideoenc.cpp   2016-01-17 20:53:18.793143645 +0100
3 @@ -38,12 +38,11 @@
4  {
5      UtVideoContext *utv = (UtVideoContext *)avctx->priv_data;
6      UtVideoExtra *info;
7 -    uint32_t flags, in_format;
8 +    uint32_t flags;
9      int ret;
10  
11      switch (avctx->pix_fmt) {
12      case AV_PIX_FMT_YUV420P:
13 -        in_format = UTVF_YV12;
14          avctx->bits_per_coded_sample = 12;
15          if (avctx->colorspace == AVCOL_SPC_BT709)
16              avctx->codec_tag = MKTAG('U', 'L', 'H', '0');
17 @@ -51,7 +50,6 @@
18              avctx->codec_tag = MKTAG('U', 'L', 'Y', '0');
19          break;
20      case AV_PIX_FMT_YUYV422:
21 -        in_format = UTVF_YUYV;
22          avctx->bits_per_coded_sample = 16;
23          if (avctx->colorspace == AVCOL_SPC_BT709)
24              avctx->codec_tag = MKTAG('U', 'L', 'H', '2');
25 @@ -59,12 +57,10 @@
26              avctx->codec_tag = MKTAG('U', 'L', 'Y', '2');
27          break;
28      case AV_PIX_FMT_BGR24:
29 -        in_format = UTVF_NFCC_BGR_BU;
30          avctx->bits_per_coded_sample = 24;
31          avctx->codec_tag = MKTAG('U', 'L', 'R', 'G');
32          break;
33      case AV_PIX_FMT_RGB32:
34 -        in_format = UTVF_NFCC_BGRA_BU;
35          avctx->bits_per_coded_sample = 32;
36          avctx->codec_tag = MKTAG('U', 'L', 'R', 'A');
37          break;
38 @@ -113,16 +109,14 @@
39       * Create a Ut Video instance. Since the function wants
40       * an "interface name" string, pass it the name of the lib.
41       */
42 -    utv->codec = CCodec::CreateInstance(UNFCC(avctx->codec_tag), "libavcodec");
43 +    utv->codec = CCodec::CreateInstance(htobe32(avctx->codec_tag), "libavcodec");
44  
45      /* Initialize encoder */
46 -    utv->codec->EncodeBegin(in_format, avctx->width, avctx->height,
47 -                            CBGROSSWIDTH_WINDOWS);
48 +    utv->codec->EncodeBegin(avctx->width, avctx->height);
49  
50      /* Get extradata from encoder */
51      avctx->extradata_size = utv->codec->EncodeGetExtraDataSize();
52 -    utv->codec->EncodeGetExtraData(info, avctx->extradata_size, in_format,
53 -                                   avctx->width, avctx->height,
54 -                                   CBGROSSWIDTH_WINDOWS);
55 +    utv->codec->EncodeGetExtraData(info, avctx->extradata_size,
56 +                                   avctx->width, avctx->height);
57      avctx->extradata = (uint8_t *)info;
58  
59 @@ -140,6 +135,7 @@
60      bool keyframe;
61      uint8_t *y, *u, *v;
62      uint8_t *dst;
63 +    uint32_t in_format;
64  
65      /* Alloc buffer */
66      if ((ret = ff_alloc_packet2(avctx, pkt, utv->buf_size, 0)) < 0)
67 @@ -150,6 +146,7 @@
68      /* Move input if needed data into Ut Video friendly buffer */
69      switch (avctx->pix_fmt) {
70      case AV_PIX_FMT_YUV420P:
71 +        in_format = UTVF_YV12;
72          y = utv->buffer;
73          u = y + w * h;
74          v = u + w * h / 4;
75 @@ -165,12 +162,14 @@
76          }
77          break;
78      case AV_PIX_FMT_YUYV422:
79 +        in_format = UTVF_YUYV;
80          for (i = 0; i < h; i++)
81              memcpy(utv->buffer + i * (w << 1),
82                     pic->data[0] + i * pic->linesize[0], w << 1);
83          break;
84      case AV_PIX_FMT_BGR24:
85      case AV_PIX_FMT_RGB32:
86 +        in_format = avctx->pix_fmt == AV_PIX_FMT_BGR24 ? UTVF_NFCC_BGR_BU : UTVF_NFCC_BGRA_BU;
87          /* Ut Video takes bottom-up BGR */
88          rgb_size = avctx->pix_fmt == AV_PIX_FMT_BGR24 ? 3 : 4;
89          for (i = 0; i < h; i++)
90 @@ -183,7 +182,7 @@
91      }
92  
93      /* Encode frame */
94 -    pkt->size = utv->codec->EncodeFrame(dst, &keyframe, utv->buffer);
95 +    pkt->size = utv->codec->EncodeFrame(dst, &keyframe, utv->buffer, in_format, CBGROSSWIDTH_WINDOWS);
96  
97      if (!pkt->size) {
98          av_log(avctx, AV_LOG_ERROR, "EncodeFrame failed!\n");
99 --- ffmpeg-2.8.5/libavcodec/libutvideodec.cpp.orig      2016-01-17 15:47:01.790581181 +0100
100 +++ ffmpeg-2.8.5/libavcodec/libutvideodec.cpp   2016-01-17 20:39:38.713177720 +0100
101 @@ -36,7 +36,6 @@
102  {
103      UtVideoContext *utv = (UtVideoContext *)avctx->priv_data;
104      UtVideoExtra info;
105 -    int format;
106      int begin_ret;
107  
108      if (avctx->extradata_size != 16 && avctx->extradata_size != 8 ) {
109 @@ -56,34 +55,27 @@
110      case MKTAG('U', 'L', 'H', '0'):
111          avctx->pix_fmt = AV_PIX_FMT_YUV420P;
112          avctx->colorspace = AVCOL_SPC_BT709;
113 -        format = UTVF_YV12;
114          break;
115      case MKTAG('U', 'L', 'H', '2'):
116          avctx->pix_fmt = AV_PIX_FMT_YUYV422;
117          avctx->colorspace = AVCOL_SPC_BT709;
118 -        format = UTVF_YUY2;
119          break;
120  #endif
121      case MKTAG('U', 'L', 'Y', '0'):
122          avctx->pix_fmt = AV_PIX_FMT_YUV420P;
123 -        format = UTVF_YV12;
124          break;
125      case MKTAG('U', 'L', 'Y', '2'):
126          avctx->pix_fmt = AV_PIX_FMT_YUYV422;
127 -        format = UTVF_YUY2;
128          break;
129      case MKTAG('U', 'L', 'R', 'G'):
130          avctx->pix_fmt = AV_PIX_FMT_BGR24;
131 -        format = UTVF_NFCC_BGR_BU;
132          break;
133      case MKTAG('U', 'L', 'R', 'A'):
134          avctx->pix_fmt = AV_PIX_FMT_RGB32;
135 -        format = UTVF_NFCC_BGRA_BU;
136          break;
137  #ifdef UTVF_UQY2
138      case MKTAG('U', 'Q', 'Y', '2'):
139          avctx->pix_fmt = AV_PIX_FMT_YUV422P10;
140 -        format = UTVF_v210;
141          break;
142  #endif
143      default:
144 @@ -95,7 +87,7 @@
145      /* Only allocate the buffer once */
146      utv->buf_size = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
147  #ifdef UTVF_UQY2
148 -    if (format == UTVF_v210)
149 +    if (avctx->pix_fmt == AV_PIX_FMT_YUV422P10)
150          utv->buf_size += avctx->height * ((avctx->width + 47) / 48) * 128; // the linesize used by the decoder, this does not seem to be exported
151  #endif
152      utv->buffer = (uint8_t *)av_malloc(utv->buf_size * sizeof(uint8_t));
153 @@ -121,11 +113,10 @@
154       * Create a Ut Video instance. Since the function wants
155       * an "interface name" string, pass it the name of the lib.
156       */
157 -    utv->codec = CCodec::CreateInstance(UNFCC(avctx->codec_tag), "libavcodec");
158 +    utv->codec = CCodec::CreateInstance(htobe32(avctx->codec_tag), "libavcodec");
159  
160      /* Initialize Decoding */
161 -    begin_ret = utv->codec->DecodeBegin(format, avctx->width, avctx->height,
162 -                            CBGROSSWIDTH_WINDOWS, &info, sizeof(UtVideoExtra));
163 +    begin_ret = utv->codec->DecodeBegin(avctx->width, avctx->height, &info, sizeof(UtVideoExtra));
164  
165      /* Check to see if the decoder initlized properly */
166      if (begin_ret != 0) {
167 @@ -143,14 +134,35 @@
168      UtVideoContext *utv = (UtVideoContext *)avctx->priv_data;
169      AVFrame *pic = avctx->coded_frame;
170      int w = avctx->width, h = avctx->height;
171 +    int format;
172  
173      /* Set flags */
174      pic->reference = 0;
175      pic->pict_type = AV_PICTURE_TYPE_I;
176      pic->key_frame = 1;
177  
178 +    switch (avctx->pix_fmt) {
179 +    case AV_PIX_FMT_YUV420P:
180 +        format = UTVF_YV12;
181 +        break;
182 +    case AV_PIX_FMT_YUYV422:
183 +        format = UTVF_YUY2;
184 +        break;
185 +    case AV_PIX_FMT_BGR24:
186 +        format = UTVF_NFCC_BGR_BU;
187 +        break;
188 +    case AV_PIX_FMT_RGB32:
189 +        format = UTVF_NFCC_BGRA_BU;
190 +        break;
191 +#ifdef UTVF_UQY2
192 +    case AV_PIX_FMT_YUV422P10:
193 +        format = UTVF_v210;
194 +        break;
195 +#endif
196 +    }
197 +
198      /* Decode the frame */
199 -    utv->codec->DecodeFrame(utv->buffer, avpkt->data, true);
200 +    utv->codec->DecodeFrame(utv->buffer, avpkt->data, format, CBGROSSWIDTH_WINDOWS);
201  
202      /* Set the output data depending on the colorspace */
203      switch (avctx->pix_fmt) {
This page took 0.099618 seconds and 2 git commands to generate.