+ }
+ }
+
+ /* Convert colorspace */
+ y_out = c->pic.data[0] + (height - 1) * c->pic.linesize[0];
+ u_out = c->pic.data[1] + (height - 1) * c->pic.linesize[1];
+ v_out = c->pic.data[2] + (height - 1) * c->pic.linesize[2];
+ switch (c->imgtype) {
+ case IMGTYPE_YUV111:
+ for (row = 0; row < height; row++) {
+ for (col = 0; col < width; col++) {
+ y_out[col] = *encoded++;
+ u_out[col] = *encoded++ + 128;
+ v_out[col] = *encoded++ + 128;
+ }
+ y_out -= c->pic.linesize[0];
+ u_out -= c->pic.linesize[1];
+ v_out -= c->pic.linesize[2];
+ }
+ break;
+ case IMGTYPE_YUV422:
+ for (row = 0; row < height; row++) {
+ for (col = 0; col < width - 3; col += 4) {
+ memcpy(y_out + col, encoded, 4);
+ encoded += 4;
+ u_out[ col >> 1 ] = *encoded++ + 128;
+ u_out[(col >> 1) + 1] = *encoded++ + 128;
+ v_out[ col >> 1 ] = *encoded++ + 128;
+ v_out[(col >> 1) + 1] = *encoded++ + 128;
+ }
+ y_out -= c->pic.linesize[0];
+ u_out -= c->pic.linesize[1];
+ v_out -= c->pic.linesize[2];
+ }
+ break;
+ case IMGTYPE_RGB24:
+ for (row = height - 1; row >= 0; row--) {
+ pixel_ptr = row * c->pic.linesize[0];
+ memcpy(outptr + pixel_ptr, encoded, 3 * width);
+ encoded += 3 * width;
+ }
+ break;
+ case IMGTYPE_YUV411:
+ for (row = 0; row < height; row++) {
+ for (col = 0; col < width - 3; col += 4) {
+ memcpy(y_out + col, encoded, 4);
+ encoded += 4;
+ u_out[col >> 2] = *encoded++ + 128;
+ v_out[col >> 2] = *encoded++ + 128;
+ }
+ y_out -= c->pic.linesize[0];
+ u_out -= c->pic.linesize[1];
+ v_out -= c->pic.linesize[2];
+ }
+ break;
+ case IMGTYPE_YUV211:
+ for (row = 0; row < height; row++) {
+ for (col = 0; col < width - 1; col += 2) {
+ memcpy(y_out + col, encoded, 2);
+ encoded += 2;
+ u_out[col >> 1] = *encoded++ + 128;
+ v_out[col >> 1] = *encoded++ + 128;
+ }
+ y_out -= c->pic.linesize[0];
+ u_out -= c->pic.linesize[1];
+ v_out -= c->pic.linesize[2];
+ }
+ break;
+ case IMGTYPE_YUV420:
+ u_out = c->pic.data[1] + ((height >> 1) - 1) * c->pic.linesize[1];
+ v_out = c->pic.data[2] + ((height >> 1) - 1) * c->pic.linesize[2];
+ for (row = 0; row < height - 1; row += 2) {
+ for (col = 0; col < width - 1; col += 2) {
+ memcpy(y_out + col, encoded, 2);
+ encoded += 2;
+ memcpy(y_out + col - c->pic.linesize[0], encoded, 2);
+ encoded += 2;
+ u_out[col >> 1] = *encoded++ + 128;
+ v_out[col >> 1] = *encoded++ + 128;
+ }
+ y_out -= c->pic.linesize[0] << 1;
+ u_out -= c->pic.linesize[1];
+ v_out -= c->pic.linesize[2];
+ }
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in image decoder.\n");
+ return -1;