Commit 86bdd9bc authored by Tristan Matthews's avatar Tristan Matthews

* #30274: video: clean up flip code

parent f3e5d962
...@@ -216,35 +216,19 @@ int VideoFrame::mirror() { ...@@ -216,35 +216,19 @@ int VideoFrame::mirror() {
return -1; return -1;
} }
uint8_t *data; auto flip_lr = [&] (unsigned idx) {
ssize_t stride; const ssize_t stride = frame_->linesize[idx];
uint8_t *data = frame_->data[idx];
// Y const ssize_t height = idx == 0 ? frame_->height : frame_->height / 2;
stride = frame_->linesize[0]; for (int i = 0; i < height; i++) {
data = frame_->data[0]; for (int j = 0,k = stride - 1; j < stride / 2; j++, k--)
for (int i = 0; i < frame_->height; i++) {
for (int j=0,k=stride-1; j < stride/2; j++, k--)
std::swap(data[j], data[k]); std::swap(data[j], data[k]);
data += stride; data += stride;
} }
};
// U for (unsigned i = 0; i < 3; ++i)
stride = frame_->linesize[1]; flip_lr(i);
data = frame_->data[1];
for (int i = 0; i < frame_->height / 2; i++) {
for (int j=0,k=stride-1; j < stride/2; j++, k--)
std::swap(data[j], data[k]);
data += stride;
}
// V
stride = frame_->linesize[2];
data = frame_->data[2];
for (int i = 0; i < frame_->height / 2; i++) {
for (int j=0,k=stride-1; j < stride/2; j++, k--)
std::swap(data[j], data[k]);
data += stride;
}
return 0; return 0;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment