Back to Resources
Technical Guide

H.265/HEVC Implementation in Embedded Systems

Technical deep-dive into H.265 codec integration for embedded vision devices, covering hardware acceleration and optimization.

SECUTRONIC Engineering
September 20, 2024
30 min read
H.265HEVCCodecVideo Compression

Introduction to H.265/HEVC

High Efficiency Video Coding (HEVC/H.265) provides 50% better compression than H.264 at equivalent quality. This guide covers implementation strategies for embedded surveillance systems.

Codec Architecture Overview

H.265 introduces several improvements over H.264:

FeatureH.264H.265
Block size16x16 max64x64 max (CTU)
Intra prediction9 modes35 modes
Motion compensationQuarter-pelQuarter-pel + bi-prediction
Transform4x4, 8x84x4 to 32x32
Loop filterDeblockingDeblocking + SAO

Hardware Encoder Integration

V4L2 Stateful Encoder API

Linux systems use V4L2 for hardware codec access:

c
// Open encoder device
int fd = open("/dev/video-enc", O_RDWR);

// Set output format (encoded H.265)
struct v4l2_format fmt = {0};
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
fmt.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_HEVC;
fmt.fmt.pix_mp.width = 1920;
fmt.fmt.pix_mp.height = 1080;
ioctl(fd, VIDIOC_S_FMT, &fmt);

// Set input format (raw YUV)
fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
fmt.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_NV12;
ioctl(fd, VIDIOC_S_FMT, &fmt);

Encoder Parameters

Critical encoding parameters for surveillance applications:

  • Profile: Main or Main 10 (for HDR)
  • Level: 5.1 supports 4K@60fps
  • Tier: High tier for higher bitrates
  • Slice structure: Single slice for low latency
  • Entropy coding: CABAC only (no CAVLC)

H.265 Main profile is sufficient for most surveillance applications. Main 10 is only needed for 10-bit color depth or HDR content.

Rate Control Modes

H.265 encoders support various rate control strategies:

ModeDescriptionSurveillance Use
CBRConstant bitrateNVR recording, bandwidth planning
VBRVariable bitrateQuality-critical scenes
CQPConstant QPTesting, benchmarking
CVBRCapped VBRBalanced quality/bandwidth

Smart Encoding Features

Region of Interest (ROI)

ROI encoding allocates more bits to important areas:

c
// Define ROI region
struct v4l2_ext_control ctrl = {0};
ctrl.id = V4L2_CID_MPEG_VIDEO_ROI;
ctrl.size = sizeof(struct v4l2_enc_roi);

struct v4l2_enc_roi roi = {
    .left = 100,
    .top = 100,
    .width = 400,
    .height = 300,
    .qp_delta = -10  // Higher quality
};
ctrl.ptr = &roi;

Smart Codec (H.265+)

Vendor-specific extensions reduce bandwidth for static scenes:

  • Background modeling: Encode static regions at lower quality
  • Skip frame insertion: Insert skip frames for unchanging scenes
  • Dynamic GOP: Extend GOP during low-motion periods
  • Typical savings: 50-70% bandwidth reduction for typical surveillance

Decoder Considerations

Client-side H.265 decoding requirements:

  • Hardware acceleration essential for 4K playback
  • Intel Quick Sync, NVIDIA NVDEC, ARM Mali widely supported
  • Browser support limited (Safari, Edge; Chrome via extensions)
  • VLC, FFmpeg provide software fallback

Bitrate Guidelines

ResolutionFrame RateRecommended Bitrate
1080p30 fps2-4 Mbps
1080p60 fps4-6 Mbps
4K30 fps8-12 Mbps
4K60 fps15-20 Mbps

Conclusion

H.265 implementation in embedded systems requires careful attention to hardware capabilities, rate control, and client compatibility. When properly configured, H.265 delivers significant storage and bandwidth savings while maintaining video quality.

Published by

SECUTRONIC Engineering

Contact Our Team