Based on ConvertToPlanar() from libutvideo libutvideo sadly does not seem to support exporting its internal planar buffers
Unified · Split
| @@ -39,7 +39,7 @@ static av_cold int utvideo_decode_init(AVCodecContext *avctx) · 38 unmodified lines | ||
| 39 | 39 | int format; |
| 40 | 40 | int begin_ret; |
| 41 | 41 | |
| 42 | − if (avctx->extradata_size != 4*4) { | |
| 42 | + if (avctx->extradata_size != 16 && avctx->extradata_size != 8 ) { | |
| 43 | 43 | av_log(avctx, AV_LOG_ERROR, "Extradata size (%d) mismatch.\n", avctx->extradata_size); |
| 44 | 44 | return -1; |
| 45 | 45 | } |
| @@ -80,6 +80,12 @@ static av_cold int utvideo_decode_init(AVCodecContext *avctx) · 34 unmodified lines | ||
| 80 | 80 | avctx->pix_fmt = AV_PIX_FMT_RGB32; |
| 81 | 81 | format = UTVF_NFCC_BGRA_BU; |
| 82 | 82 | break; |
| 83 | +#ifdef UTVF_UQY2 | |
| 84 | + case MKTAG('U', 'Q', 'Y', '2'): | |
| 85 | + avctx->pix_fmt = AV_PIX_FMT_YUV422P10; | |
| 86 | + format = UTVF_v210; | |
| 87 | + break; | |
| 88 | +#endif | |
| 83 | 89 | default: |
| 84 | 90 | av_log(avctx, AV_LOG_ERROR, |
| 85 | 91 | "Not a Ut Video FOURCC: %X\n", avctx->codec_tag); |
| @@ -88,6 +94,8 @@ static av_cold int utvideo_decode_init(AVCodecContext *avctx) · 2 unmodified lines | ||
| 88 | 94 | |
| 89 | 95 | /* Only allocate the buffer once */ |
| 90 | 96 | utv->buf_size = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); |
| 97 | + if (format == UTVF_v210) | |
| 98 | + utv->buf_size += avctx->height * ((avctx->width + 47) / 48) * 128; // the linesize used by the decoder, this does not seem to be exported | |
| 91 | 99 | utv->buffer = (uint8_t *)av_malloc(utv->buf_size * sizeof(uint8_t)); |
| 92 | 100 | |
| 93 | 101 | if (utv->buffer == NULL) { |
| @@ -155,6 +163,56 @@ static int utvideo_decode_frame(AVCodecContext *avctx, void *data, · 61 unmodified lines | ||
| 155 | 163 | pic->linesize[0] = w * 2; |
| 156 | 164 | pic->data[0] = utv->buffer; |
| 157 | 165 | break; |
| 166 | + case AV_PIX_FMT_YUV422P10: { | |
| 167 | + uint16_t *y, *u, *v; | |
| 168 | + int i,j; | |
| 169 | + int linesize = ((w + 47) / 48) * 128; | |
| 170 | + | |
| 171 | + pic->linesize[0] = w * 2; | |
| 172 | + pic->linesize[1] = | |
| 173 | + pic->linesize[2] = w; | |
| 174 | + pic->data[0] = utv->buffer + linesize * h; | |
| 175 | + pic->data[1] = pic->data[0] + h*pic->linesize[0]; | |
| 176 | + pic->data[2] = pic->data[1] + h*pic->linesize[1]; | |
| 177 | + y = (uint16_t*)pic->data[0]; | |
| 178 | + u = (uint16_t*)pic->data[1]; | |
| 179 | + v = (uint16_t*)pic->data[2]; | |
| 180 | + for (j = 0; j < h; j++) { | |
| 181 | + const uint8_t *in = utv->buffer + j * linesize; | |
| 182 | + | |
| 183 | + for (i = 0; i + 1 < w; i += 6, in += 4) { | |
| 184 | + unsigned a,b; | |
| 185 | + a = AV_RL32(in); | |
| 186 | + in += 4; | |
| 187 | + b = AV_RL32(in); | |
| 188 | + *u++ = (a ) & 0x3FF; | |
| 189 | + *y++ = (a>>10) & 0x3FF; | |
| 190 | + *v++ = (a>>20) & 0x3FF; | |
| 191 | + *y++ = (b ) & 0x3FF; | |
| 192 | + | |
| 193 | + if (i + 3 >= w) | |
| 194 | + break; | |
| 195 | + | |
| 196 | + in += 4; | |
| 197 | + a = AV_RL32(in); | |
| 198 | + *u++ = (b>>10) & 0x3FF; | |
| 199 | + *y++ = (b>>20) & 0x3FF; | |
| 200 | + *v++ = (a ) & 0x3FF; | |
| 201 | + *y++ = (a>>10) & 0x3FF; | |
| 202 | + | |
| 203 | + if (i + 5 >= w) | |
| 204 | + break; | |
| 205 | + | |
| 206 | + in += 4; | |
| 207 | + b = AV_RL32(in); | |
| 208 | + *u++ = (a>>20) & 0x3FF; | |
| 209 | + *y++ = (b ) & 0x3FF; | |
| 210 | + *v++ = (b>>10) & 0x3FF; | |
| 211 | + *y++ = (b>>20) & 0x3FF; | |
| 212 | + } | |
| 213 | + } | |
| 214 | + break; | |
| 215 | + } | |
| 158 | 216 | case AV_PIX_FMT_BGR24: |
| 159 | 217 | case AV_PIX_FMT_RGB32: |
| 160 | 218 | /* Make the linesize negative, since Ut Video uses bottom-up BGR */ |