On Tue, Oct 25, 2016 at 10:36 AM, yihungbakj hung <
yihun...@gmail.com> wrote:
> Hi Niels
>
> On your suggestion I refactored this bit of code as follows. I used
> CropAndScaleFrom instead of StretchToPlanes.
> buffer b(frameSize);
> int halfW = (w+1)/2, halfH = (h+1)/2;
> uint8_t *y = (uint8_t *)b.get_data();
> uint8_t *u = y + w*h;
> uint8_t *v = u + halfW*halfH;
>
> #if 0
> frame->StretchToPlanes(y, u, v, w, halfW, halfW, w, h, true, true);
> #else
Since it seems you want to the scaled data into a contiguous buffer
where you have full control over the layout, and you already have code
to avoid aspect-ratio related distortion, I'd suggest using libyuv
directly. I.e.,
#include "libyuv/scale.h"
rtc::scoped_refptr<webrtc::VideoFrameBuffer> srcBuf(
frame->video_frame_buffer());
libyuv::I420Scale(srcBuf->DataY(), srcBuf->StrideY(),
srcBuf->DataU(), srcBuf->StrideU(),
srcBuf->DataV(), srcBuf->StrideV(),
frameW, frameH,
y, w, u, halfW, v, halfW,
w, h, libyuv::kFilterBox);
This should write the scaled image into your buffer b, in the same way
as StretchToPlanes did.
Then I'm afraid you have some additional obstacles to get your code
working with latest webrtc. GetCopyWithRotationApplied was deleted
some month ago, see
https://codereview.chromium.org/2293253003/patch/1/10001 for an
example on how to handle it using webrtc::I420Buffer::Rotate instead,
followed by deprecation of cricket::VideoFrame (now an alias for
webrtc::VideoFrame).
Regards,
/Niels