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
5 UtVideoContext *utv = (UtVideoContext *)avctx->priv_data;
7 - uint32_t flags, in_format;
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');
18 avctx->codec_tag = MKTAG('U', 'L', 'Y', '0');
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');
26 avctx->codec_tag = MKTAG('U', 'L', 'Y', '2');
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');
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');
39 * Create a Ut Video instance. Since the function wants
40 * an "interface name" string, pass it the name of the lib.
42 - utv->codec = CCodec::CreateInstance(UNFCC(avctx->codec_tag), "libavcodec");
43 + utv->codec = CCodec::CreateInstance(htobe32(avctx->codec_tag), "libavcodec");
45 /* Initialize encoder */
46 - utv->codec->EncodeBegin(in_format, avctx->width, avctx->height,
47 - CBGROSSWIDTH_WINDOWS);
48 + utv->codec->EncodeBegin(avctx->width, avctx->height);
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;
66 if ((ret = ff_alloc_packet2(avctx, pkt, utv->buf_size, 0)) < 0)
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;
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);
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++)
94 - pkt->size = utv->codec->EncodeFrame(dst, &keyframe, utv->buffer);
95 + pkt->size = utv->codec->EncodeFrame(dst, &keyframe, utv->buffer, in_format, CBGROSSWIDTH_WINDOWS);
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
103 UtVideoContext *utv = (UtVideoContext *)avctx->priv_data;
108 if (avctx->extradata_size != 16 && avctx->extradata_size != 8 ) {
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;
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;
121 case MKTAG('U', 'L', 'Y', '0'):
122 avctx->pix_fmt = AV_PIX_FMT_YUV420P;
123 - format = UTVF_YV12;
125 case MKTAG('U', 'L', 'Y', '2'):
126 avctx->pix_fmt = AV_PIX_FMT_YUYV422;
127 - format = UTVF_YUY2;
129 case MKTAG('U', 'L', 'R', 'G'):
130 avctx->pix_fmt = AV_PIX_FMT_BGR24;
131 - format = UTVF_NFCC_BGR_BU;
133 case MKTAG('U', 'L', 'R', 'A'):
134 avctx->pix_fmt = AV_PIX_FMT_RGB32;
135 - format = UTVF_NFCC_BGRA_BU;
138 case MKTAG('U', 'Q', 'Y', '2'):
139 avctx->pix_fmt = AV_PIX_FMT_YUV422P10;
140 - format = UTVF_v210;
145 /* Only allocate the buffer once */
146 utv->buf_size = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
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
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.
157 - utv->codec = CCodec::CreateInstance(UNFCC(avctx->codec_tag), "libavcodec");
158 + utv->codec = CCodec::CreateInstance(htobe32(avctx->codec_tag), "libavcodec");
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));
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;
175 pic->pict_type = AV_PICTURE_TYPE_I;
178 + switch (avctx->pix_fmt) {
179 + case AV_PIX_FMT_YUV420P:
180 + format = UTVF_YV12;
182 + case AV_PIX_FMT_YUYV422:
183 + format = UTVF_YUY2;
185 + case AV_PIX_FMT_BGR24:
186 + format = UTVF_NFCC_BGR_BU;
188 + case AV_PIX_FMT_RGB32:
189 + format = UTVF_NFCC_BGRA_BU;
192 + case AV_PIX_FMT_YUV422P10:
193 + format = UTVF_v210;
198 /* Decode the frame */
199 - utv->codec->DecodeFrame(utv->buffer, avpkt->data, true);
200 + utv->codec->DecodeFrame(utv->buffer, avpkt->data, format, CBGROSSWIDTH_WINDOWS);
202 /* Set the output data depending on the colorspace */
203 switch (avctx->pix_fmt) {