Feature: convert nv12(yuv420sp) to yuv420p

pull/221/head
xufuji456 2 years ago
parent 5a642a992f
commit 70cb21cf5c
  1. 12
      app/src/main/cpp/yuv/yuv_converter.cpp
  2. 8
      app/src/main/cpp/yuv/yuv_converter.h

@ -114,7 +114,15 @@ static void nv21_to_yuv420p(int8_t *dst, int8_t *src, int len) {
}
}
static void yuv420p_rotate90(int8_t *dst, int8_t *src, int width, int height) {
static void nv12_to_yuv420p(int8_t *dst, int8_t *src, int len) {
memcpy(dst, src, len); // y
for (int i = 0; i < len / 4; ++i) {
*(dst + len + i) = *(src + len + i * 2); // u
*(dst + len * 5 / 4 + i) = *(src + len + i * 2 + 1); // v
}
}
static void yuv420p_rotate90(int8_t *dst, const int8_t *src, int width, int height) {
int n = 0;
int wh = width * height;
int half_width = width / 2;
@ -139,7 +147,7 @@ static void yuv420p_rotate90(int8_t *dst, int8_t *src, int width, int height) {
}
}
static void yuv420p_rotate180(int8_t *dst, int8_t *src, int width, int height) {
static void yuv420p_rotate180(int8_t *dst, const int8_t *src, int width, int height) {
int n = 0;
int half_width = width / 2;
int half_height = height / 2;

@ -21,4 +21,12 @@ static void yuv420p_rotate(int8_t *dst, int8_t *src, int width, int height, int
*/
static void nv21_to_yuv420p(int8_t *dst, int8_t *src, int len);
/**
* convert NV12 to YUV420P
* @param dst data of yuv420p
* @param src data of nv12
* @param len width*height
*/
static void nv12_to_yuv420p(int8_t *dst, int8_t *src, int len);
#endif //FFMPEGANDROID_YUV_CONVERTER_H

Loading…
Cancel
Save