修复花屏4
This commit is contained in:
parent
9c18773e65
commit
d7c944d898
@ -7,6 +7,7 @@
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
@ -323,7 +324,8 @@ bool MinioUploader::Init(const SimpleJson& config) {
|
||||
use_ssl_ = endpoint_.find("https://") == 0;
|
||||
|
||||
#if HAS_CURL
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
static std::once_flag curl_once;
|
||||
std::call_once(curl_once, [] { curl_global_init(CURL_GLOBAL_DEFAULT); });
|
||||
#endif
|
||||
|
||||
if (presign_endpoint_.empty() && (access_key_.empty() || secret_key_.empty())) {
|
||||
|
||||
@ -105,7 +105,12 @@ bool CopyToStridedBuffer(const Frame& src, uint8_t* dst, size_t dst_size,
|
||||
const uint8_t* src_uv = src.planes[1].data ? src.planes[1].data : nullptr;
|
||||
const int src_y_stride = src.planes[0].stride > 0 ? src.planes[0].stride : w;
|
||||
const int src_uv_stride = src.planes[1].stride > 0 ? src.planes[1].stride : w;
|
||||
if (!src_y || !src_uv) return false;
|
||||
if (!src_y) return false;
|
||||
if (!src_uv) {
|
||||
// Fallback: packed NV12 layout.
|
||||
if (!src.data) return false;
|
||||
src_uv = src.data + static_cast<size_t>(src_y_stride) * static_cast<size_t>(h);
|
||||
}
|
||||
|
||||
for (int row = 0; row < h; ++row) {
|
||||
std::memcpy(dst + static_cast<size_t>(row) * dst_wstride,
|
||||
@ -309,11 +314,31 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
// Calculate proper strides (RGA requires aligned strides)
|
||||
// For YUV formats, wstride is the width of Y plane
|
||||
// For RGB/BGR formats, wstride is width (not width*3)
|
||||
// Calculate proper strides.
|
||||
// IMPORTANT: For DMA-BUF frames (e.g. MPP decode output), the actual vertical stride
|
||||
// (ver_stride) may be larger than `height`. We must honor that, otherwise RGA will
|
||||
// read UV from the wrong offset (典型花屏/错色).
|
||||
int src_wstride = Align16(frame->width);
|
||||
int src_hstride = Align16(frame->height);
|
||||
if (frame->format == PixelFormat::NV12 || frame->format == PixelFormat::YUV420) {
|
||||
const int y_stride = frame->planes[0].stride > 0 ? frame->planes[0].stride
|
||||
: (frame->stride > 0 ? frame->stride : frame->width);
|
||||
if (y_stride > 0) src_wstride = y_stride;
|
||||
if (frame->planes[0].size > 0 && y_stride > 0) {
|
||||
const int hs = frame->planes[0].size / y_stride;
|
||||
if (hs >= frame->height) src_hstride = hs;
|
||||
}
|
||||
} else if (frame->format == PixelFormat::RGB || frame->format == PixelFormat::BGR) {
|
||||
const int stride_bytes = frame->planes[0].stride > 0 ? frame->planes[0].stride
|
||||
: (frame->stride > 0 ? frame->stride : frame->width * 3);
|
||||
if (stride_bytes > 0 && (stride_bytes % 3) == 0) {
|
||||
src_wstride = stride_bytes / 3;
|
||||
}
|
||||
if (frame->planes[0].size > 0 && stride_bytes > 0) {
|
||||
const int hs = frame->planes[0].size / stride_bytes;
|
||||
if (hs >= frame->height) src_hstride = hs;
|
||||
}
|
||||
}
|
||||
int dst_wstride = Align16(out_w);
|
||||
int dst_hstride = Align16(out_h);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user