]>
Commit | Line | Data |
---|---|---|
c0d43f3d JB |
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; | |
ad057c0a | 10 | |
ad057c0a | 11 | switch (avctx->pix_fmt) { |
c0d43f3d JB |
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 | ||
ad057c0a JB |
50 | /* Get extradata from encoder */ |
51 | avctx->extradata_size = utv->codec->EncodeGetExtraDataSize(); | |
c0d43f3d | 52 | - utv->codec->EncodeGetExtraData(info, avctx->extradata_size, in_format, |
ad057c0a JB |
53 | - avctx->width, avctx->height, |
54 | - CBGROSSWIDTH_WINDOWS); | |
c0d43f3d | 55 | + utv->codec->EncodeGetExtraData(info, avctx->extradata_size, |
ad057c0a JB |
56 | + avctx->width, avctx->height); |
57 | avctx->extradata = (uint8_t *)info; | |
58 | ||
bd64dc4c | 59 | @@ -140,6 +134,7 @@ |
c0d43f3d JB |
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) | |
bd64dc4c | 67 | @@ -150,6 +145,7 @@ |
c0d43f3d JB |
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; | |
bd64dc4c | 75 | @@ -165,12 +161,14 @@ |
c0d43f3d JB |
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++) | |
bd64dc4c | 90 | @@ -183,7 +181,7 @@ |
c0d43f3d JB |
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) { | |
bd64dc4c | 167 | @@ -143,13 +134,34 @@ |
c0d43f3d JB |
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 | ||
ad057c0a | 173 | /* Set flags */ |
c0d43f3d JB |
174 | pic->pict_type = AV_PICTURE_TYPE_I; |
175 | pic->key_frame = 1; | |
176 | ||
177 | + switch (avctx->pix_fmt) { | |
178 | + case AV_PIX_FMT_YUV420P: | |
179 | + format = UTVF_YV12; | |
180 | + break; | |
181 | + case AV_PIX_FMT_YUYV422: | |
182 | + format = UTVF_YUY2; | |
183 | + break; | |
184 | + case AV_PIX_FMT_BGR24: | |
185 | + format = UTVF_NFCC_BGR_BU; | |
186 | + break; | |
187 | + case AV_PIX_FMT_RGB32: | |
188 | + format = UTVF_NFCC_BGRA_BU; | |
189 | + break; | |
190 | +#ifdef UTVF_UQY2 | |
191 | + case AV_PIX_FMT_YUV422P10: | |
192 | + format = UTVF_v210; | |
193 | + break; | |
194 | +#endif | |
195 | + } | |
196 | + | |
197 | /* Decode the frame */ | |
198 | - utv->codec->DecodeFrame(utv->buffer, avpkt->data, true); | |
199 | + utv->codec->DecodeFrame(utv->buffer, avpkt->data, format, CBGROSSWIDTH_WINDOWS); | |
200 | ||
201 | /* Set the output data depending on the colorspace */ | |
202 | switch (avctx->pix_fmt) { |