- opic.data[0] = frame->get_y();
- opic.data[1] = frame->get_u();
- opic.data[2] = frame->get_v();
- }
-
- convert_ctx = sws_getCachedContext(convert_ctx, frame->get_w(), frame->get_h(), ifmt,
- ow, oh, ofmt, SWS_BICUBIC, NULL, NULL, NULL);
+ opic->data[0] = frame->get_y(); opic->linesize[0] = ysz;
+ opic->data[1] = frame->get_u(); opic->linesize[1] = usz;
+ opic->data[2] = frame->get_v(); opic->linesize[2] = usz;
+ break;
+ default:
+ opic->data[0] = frame->get_data();
+ opic->linesize[0] = frame->get_bytes_per_line();
+ break;
+ }
+
+ AVPixelFormat ofmt = (AVPixelFormat)op->format;
+ convert_ctx = sws_getCachedContext(convert_ctx, frame->get_w(), frame->get_h(),
+ ifmt, op->width, op->height, ofmt, SWS_BICUBIC, NULL, NULL, NULL);