+ case AV_PIX_FMT_YUV420P16:
+ {
+ uint16_t *ptr1, *ptr2;
+ const int f = (65535 * 32768 + s->maxval / 2) / s->maxval;
+ unsigned int j, v;
+
+ n = avctx->width * 2;
+ ptr = p->data[0];
+ linesize = p->linesize[0];
+ if (s->bytestream + n * avctx->height * 3 / 2 > s->bytestream_end)
+ return AVERROR_INVALIDDATA;
+ for (i = 0; i < avctx->height; i++) {
+ for (j = 0; j < n / 2; j++) {
+ v = av_be2ne16(((uint16_t *)s->bytestream)[j]);
+ ((uint16_t *)ptr)[j] = (v * f + 16384) >> 15;
+ }
+ s->bytestream += n;
+ ptr += linesize;
+ }
+ ptr1 = (uint16_t*)p->data[1];
+ ptr2 = (uint16_t*)p->data[2];
+ n >>= 1;
+ h = avctx->height >> 1;
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < n / 2; j++) {
+ v = av_be2ne16(((uint16_t *)s->bytestream)[j]);
+ ptr1[j] = (v * f + 16384) >> 15;
+ }
+ s->bytestream += n;
+
+ for (j = 0; j < n / 2; j++) {
+ v = av_be2ne16(((uint16_t *)s->bytestream)[j]);
+ ptr2[j] = (v * f + 16384) >> 15;
+ }
+ s->bytestream += n;
+
+ ptr1 += p->linesize[1] / 2;
+ ptr2 += p->linesize[2] / 2;
+ }
+ }
+ break;