JavaCPP bindings for FFmpeg multimedia framework providing comprehensive Java access to audio/video encoding, decoding, filtering, and format conversion
—
Video post-processing operations for enhancing decoded video quality through filtering techniques like deblocking, deringing, and color correction.
/**
* Create a post-processing context for video enhancement
* @param width Video frame width in pixels
* @param height Video frame height in pixels
* @param flags CPU capability flags for optimization
* @return Post-processing context or null on failure
*/
pp_context pp_get_context(int width, int height, int flags);
/**
* Free post-processing context and associated resources
* @param ppContext Context to deallocate
*/
void pp_free_context(pp_context ppContext);Usage Example:
import org.bytedeco.ffmpeg.postproc.*;
import static org.bytedeco.ffmpeg.global.postproc.*;
// Create post-processing context for 1920x1080 video
pp_context context = pp_get_context(1920, 1080, PP_CPU_CAPS_AUTO);
try {
// Use context for post-processing operations
} finally {
pp_free_context(context);
}/**
* Create post-processing mode from name and quality level
* @param name Processing mode specification string
* @param quality Quality level from 0 to PP_QUALITY_MAX (6)
* @return Processing mode or null if invalid
*/
pp_mode pp_get_mode_by_name_and_quality(String name, int quality);
/**
* Free post-processing mode configuration
* @param mode Mode to deallocate
*/
void pp_free_mode(pp_mode mode);Usage Example:
// Create deblocking mode with quality level 4
pp_mode deblockMode = pp_get_mode_by_name_and_quality("de", 4);
// Create comprehensive filtering mode with maximum quality
pp_mode fullMode = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a", PP_QUALITY_MAX);
try {
// Use mode for processing
} finally {
pp_free_mode(deblockMode);
pp_free_mode(fullMode);
}/**
* Apply post-processing filters to video frame data
* @param src Source image planes (Y, U, V for YUV formats)
* @param srcStride Source line sizes for each plane
* @param dst Destination image planes
* @param dstStride Destination line sizes for each plane
* @param horizontalSize Frame width in pixels
* @param verticalSize Frame height in pixels
* @param QP_store Quantization parameter values (optional, can be null)
* @param QP_stride Stride for quantization parameter array
* @param mode Post-processing mode configuration
* @param ppContext Post-processing context
* @param pict_type Picture type (I, P, B frame indicator)
*/
void pp_postprocess(PointerPointer src, IntPointer srcStride,
PointerPointer dst, IntPointer dstStride,
int horizontalSize, int verticalSize,
BytePointer QP_store, int QP_stride,
pp_mode mode, pp_context ppContext, int pict_type);Usage Example:
import org.bytedeco.ffmpeg.avutil.*;
import org.bytedeco.ffmpeg.postproc.*;
import static org.bytedeco.ffmpeg.global.avutil.*;
import static org.bytedeco.ffmpeg.global.postproc.*;
// Assuming decoded AVFrame is available
AVFrame srcFrame = /* decoded frame */;
AVFrame dstFrame = av_frame_alloc();
// Allocate destination frame with same properties
av_frame_copy_props(dstFrame, srcFrame);
dstFrame.format(srcFrame.format());
dstFrame.width(srcFrame.width());
dstFrame.height(srcFrame.height());
av_frame_get_buffer(dstFrame, 32);
// Set up post-processing
pp_context context = pp_get_context(srcFrame.width(), srcFrame.height(), PP_CPU_CAPS_AUTO);
pp_mode mode = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a", 4);
try {
// Apply post-processing
pp_postprocess(srcFrame.data(), srcFrame.linesize(),
dstFrame.data(), dstFrame.linesize(),
srcFrame.width(), srcFrame.height(),
null, 0, // No quantization data
mode, context, 0);
// dstFrame now contains post-processed video
} finally {
pp_free_mode(mode);
pp_free_context(context);
av_frame_free(dstFrame);
}The mode string can contain combinations of the following filters:
hb - Horizontal deblocking filtervb - Vertical deblocking filterdr - Deringing filter (reduces ringing artifacts)tn - Temporal noise reductional - Automatic luminance correctionfd - Force deblocking (stronger than hb/vb)Each filter can be modified with quality indicators:
a - Automatic quality (recommended)c - Chrominance processingy - Luminance processing only// Basic deblocking
pp_mode basic = pp_get_mode_by_name_and_quality("hb,vb", 3);
// Comprehensive filtering
pp_mode comprehensive = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a", 5);
// Noise reduction focused
pp_mode denoising = pp_get_mode_by_name_and_quality("tn:64:128:256", 4);
// Maximum quality processing
pp_mode maxQuality = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a,al", PP_QUALITY_MAX);// CPU capability constants for context creation
int PP_CPU_CAPS_MMX = 0x80000000; // MMX instructions
int PP_CPU_CAPS_MMX2 = 0x20000000; // MMX2 instructions
int PP_CPU_CAPS_3DNOW = 0x40000000; // 3DNow! instructions
int PP_CPU_CAPS_ALTIVEC = 0x10000000; // AltiVec instructions
int PP_CPU_CAPS_AUTO = 0x00080000; // Auto-detect capabilities/**
* Get libpostproc version information
* @return Version number as integer
*/
int postproc_version();
/**
* Get build configuration string
* @return Configuration details
*/
BytePointer postproc_configuration();
/**
* Get library license information
* @return License text
*/
BytePointer postproc_license();int PP_QUALITY_MAX = 6; // Maximum quality level for processing modesPost-processing contexts and modes must be explicitly freed:
// Always pair allocation with deallocation
pp_context context = pp_get_context(width, height, flags);
pp_mode mode = pp_get_mode_by_name_and_quality(modeString, quality);
try {
// Use context and mode
} finally {
pp_free_mode(mode); // Free mode first
pp_free_context(context); // Then free context
}Post-processing is typically applied after video decoding:
// 1. Decode frame
AVFrame decodedFrame = /* from decoder */;
// 2. Create post-processing context
pp_context ppContext = pp_get_context(
decodedFrame.width(), decodedFrame.height(), PP_CPU_CAPS_AUTO);
pp_mode ppMode = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a", 4);
// 3. Allocate output frame
AVFrame enhancedFrame = av_frame_alloc();
av_frame_copy_props(enhancedFrame, decodedFrame);
enhancedFrame.format(decodedFrame.format());
enhancedFrame.width(decodedFrame.width());
enhancedFrame.height(decodedFrame.height());
av_frame_get_buffer(enhancedFrame, 32);
// 4. Apply post-processing
pp_postprocess(decodedFrame.data(), decodedFrame.linesize(),
enhancedFrame.data(), enhancedFrame.linesize(),
decodedFrame.width(), decodedFrame.height(),
null, 0, ppMode, ppContext, 0);
// 5. Use enhanced frame for display or further processingInstall with Tessl CLI
npx tessl i tessl/maven-org-bytedeco--ffmpeg