History

avcodec/libutvideodec: Support YUV422P10

Based on ConvertToPlanar() from libutvideo libutvideo sadly does not seem to support exporting its internal planar buffers

Michael Niedermayer committed 12 years ago

Commit 59a47921 parent 4ba54201 file · +59 −1Browse files

Unified · Split

libavcodec/libutvideodec.cpp+59−1
@@ -39,7 +39,7 @@ static av_cold int utvideo_decode_init(AVCodecContext *avctx) · 38 unmodified lines
3939 int format;
4040 int begin_ret;
4141
42− if (avctx->extradata_size != 4*4) {
42+ if (avctx->extradata_size != 16 && avctx->extradata_size != 8 ) {
4343 av_log(avctx, AV_LOG_ERROR, "Extradata size (%d) mismatch.\n", avctx->extradata_size);
4444 return -1;
4545 }
@@ -80,6 +80,12 @@ static av_cold int utvideo_decode_init(AVCodecContext *avctx) · 34 unmodified lines
8080 avctx->pix_fmt = AV_PIX_FMT_RGB32;
8181 format = UTVF_NFCC_BGRA_BU;
8282 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
8389 default:
8490 av_log(avctx, AV_LOG_ERROR,
8591 "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
8894
8995 /* Only allocate the buffer once */
9096 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
9199 utv->buffer = (uint8_t *)av_malloc(utv->buf_size * sizeof(uint8_t));
92100
93101 if (utv->buffer == NULL) {
@@ -155,6 +163,56 @@ static int utvideo_decode_frame(AVCodecContext *avctx, void *data, · 61 unmodified lines
155163 pic->linesize[0] = w * 2;
156164 pic->data[0] = utv->buffer;
157165 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+ }
158216 case AV_PIX_FMT_BGR24:
159217 case AV_PIX_FMT_RGB32:
160218 /* Make the linesize negative, since Ut Video uses bottom-up BGR */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t