Skip to content

Commit 11ab63c

Browse files
Merge pull request #63 from OpenHD/codex/add-nv21-support-to-fpvue
Add NV21 support for raw input and Allwinner OMX
2 parents 0fb8c4e + 4f69960 commit 11ab63c

3 files changed

Lines changed: 147 additions & 58 deletions

File tree

allwinnerv4l2display.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ bool AllwinnerV4L2Display::setup_drm() {
175175
m_display_width,
176176
m_display_height,
177177
m_display_vrefresh,
178-
DRM_FORMAT_NV12,
178+
DRM_FORMAT_NV21,
179179
MODESET_PLANE_TYPE_PRIMARY) < 0) {
180180
std::cerr << "modeset_prepare failed" << std::endl;
181181
return false;
@@ -240,7 +240,7 @@ bool AllwinnerV4L2Display::ensure_display_buffers(uint32_t width, uint32_t heigh
240240
recycle_display_buffers();
241241

242242
debug_log("cedar", "Allocating ", kDisplayBufferCount,
243-
" DRM NV12 buffers for ", width, "x", height);
243+
" DRM NV21 buffers for ", width, "x", height);
244244

245245
m_drm_buffers.resize(kDisplayBufferCount);
246246
uint32_t stride = width;
@@ -272,7 +272,7 @@ bool AllwinnerV4L2Display::ensure_display_buffers(uint32_t width, uint32_t heigh
272272
if (drmModeAddFB2(m_drm_fd,
273273
width,
274274
height,
275-
DRM_FORMAT_NV12,
275+
DRM_FORMAT_NV21,
276276
handles,
277277
pitches,
278278
offsets,
@@ -575,7 +575,7 @@ void AllwinnerV4L2Display::teardown_omx() {
575575
m_decoder_state = OMX_StateLoaded;
576576
}
577577

578-
static void copy_planar_to_nv12(uint8_t* dst,
578+
static void copy_planar_to_nv21(uint8_t* dst,
579579
uint32_t dst_stride,
580580
uint32_t dst_uv_stride,
581581
const uint8_t* src,
@@ -595,8 +595,8 @@ static void copy_planar_to_nv12(uint8_t* dst,
595595
const uint8_t* u_row = src_u + row * (width / 2);
596596
const uint8_t* v_row = src_v + row * (width / 2);
597597
for (uint32_t col = 0; col < width / 2; ++col) {
598-
dst_row[2 * col] = u_row[col];
599-
dst_row[2 * col + 1] = v_row[col];
598+
dst_row[2 * col] = v_row[col];
599+
dst_row[2 * col + 1] = u_row[col];
600600
}
601601
}
602602
}
@@ -725,7 +725,7 @@ void AllwinnerV4L2Display::decode_loop() {
725725
} else if (output_buffer->nFilledLen > 0) {
726726
auto& drm_buf = m_drm_buffers[m_drm_buffer_index];
727727
uint8_t* dst = static_cast<uint8_t*>(drm_buf.map);
728-
copy_planar_to_nv12(dst,
728+
copy_planar_to_nv21(dst,
729729
m_display_stride,
730730
m_display_stride,
731731
output_buffer->pBuffer + output_buffer->nOffset,

display_host_main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,13 +442,13 @@ static std::string build_sample_video_pipeline_command(const char *debug_sample_
442442
<< " gst-launch-1.0 -q filesrc location=" << debug_sample_path
443443
<< " ! qtdemux name=demux demux.video_0 ! h264parse config-interval=1"
444444
<< " ! video/x-h264,stream-format=byte-stream,alignment=au ! queue ! \"$decoder\""
445-
<< " ! videoconvert ! video/x-raw,format=NV12,width=1280,height=720 ! queue ! fdsink fd=1 sync=false;\n"
445+
<< " ! videoconvert ! video/x-raw,format=NV21,width=1280,height=720 ! queue ! fdsink fd=1 sync=false;\n"
446446
<< "}\n"
447447
<< "(run_decoder omxh264dec || run_decoder mppvideodec || run_decoder avdec_h264)";
448448

449449
std::string pipeline_command = "(";
450450
pipeline_command += pipeline_builder.str();
451-
pipeline_command += ") | fpvue --screen-mode 1280x720@60 --stdin-nv12";
451+
pipeline_command += ") | fpvue --screen-mode 1280x720@60 --stdin-nv21";
452452
return pipeline_command;
453453
}
454454

0 commit comments

Comments
 (0)