or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

audio-processing.mdcodec-operations.mdcommand-line-tools.mdconstants-enums.mdcryptographic-security.mddevice-io.mdformat-handling.mdhardware-acceleration.mdindex.mdmedia-filtering.mdpostproc.mdscaling-conversion.md

postproc.mddocs/

0

# Video Post-Processing

1

2

Video post-processing operations for enhancing decoded video quality through filtering techniques like deblocking, deringing, and color correction.

3

4

## Capabilities

5

6

### Post-Processing Context Management

7

8

#### Creating Processing Context

9

10

```java { .api }

11

/**

12

* Create a post-processing context for video enhancement

13

* @param width Video frame width in pixels

14

* @param height Video frame height in pixels

15

* @param flags CPU capability flags for optimization

16

* @return Post-processing context or null on failure

17

*/

18

pp_context pp_get_context(int width, int height, int flags);

19

20

/**

21

* Free post-processing context and associated resources

22

* @param ppContext Context to deallocate

23

*/

24

void pp_free_context(pp_context ppContext);

25

```

26

27

**Usage Example:**

28

29

```java

30

import org.bytedeco.ffmpeg.postproc.*;

31

import static org.bytedeco.ffmpeg.global.postproc.*;

32

33

// Create post-processing context for 1920x1080 video

34

pp_context context = pp_get_context(1920, 1080, PP_CPU_CAPS_AUTO);

35

36

try {

37

// Use context for post-processing operations

38

} finally {

39

pp_free_context(context);

40

}

41

```

42

43

### Post-Processing Mode Configuration

44

45

#### Creating Processing Modes

46

47

```java { .api }

48

/**

49

* Create post-processing mode from name and quality level

50

* @param name Processing mode specification string

51

* @param quality Quality level from 0 to PP_QUALITY_MAX (6)

52

* @return Processing mode or null if invalid

53

*/

54

pp_mode pp_get_mode_by_name_and_quality(String name, int quality);

55

56

/**

57

* Free post-processing mode configuration

58

* @param mode Mode to deallocate

59

*/

60

void pp_free_mode(pp_mode mode);

61

```

62

63

**Usage Example:**

64

65

```java

66

// Create deblocking mode with quality level 4

67

pp_mode deblockMode = pp_get_mode_by_name_and_quality("de", 4);

68

69

// Create comprehensive filtering mode with maximum quality

70

pp_mode fullMode = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a", PP_QUALITY_MAX);

71

72

try {

73

// Use mode for processing

74

} finally {

75

pp_free_mode(deblockMode);

76

pp_free_mode(fullMode);

77

}

78

```

79

80

### Video Frame Post-Processing

81

82

#### Processing Operations

83

84

```java { .api }

85

/**

86

* Apply post-processing filters to video frame data

87

* @param src Source image planes (Y, U, V for YUV formats)

88

* @param srcStride Source line sizes for each plane

89

* @param dst Destination image planes

90

* @param dstStride Destination line sizes for each plane

91

* @param horizontalSize Frame width in pixels

92

* @param verticalSize Frame height in pixels

93

* @param QP_store Quantization parameter values (optional, can be null)

94

* @param QP_stride Stride for quantization parameter array

95

* @param mode Post-processing mode configuration

96

* @param ppContext Post-processing context

97

* @param pict_type Picture type (I, P, B frame indicator)

98

*/

99

void pp_postprocess(PointerPointer src, IntPointer srcStride,

100

PointerPointer dst, IntPointer dstStride,

101

int horizontalSize, int verticalSize,

102

BytePointer QP_store, int QP_stride,

103

pp_mode mode, pp_context ppContext, int pict_type);

104

```

105

106

**Usage Example:**

107

108

```java

109

import org.bytedeco.ffmpeg.avutil.*;

110

import org.bytedeco.ffmpeg.postproc.*;

111

import static org.bytedeco.ffmpeg.global.avutil.*;

112

import static org.bytedeco.ffmpeg.global.postproc.*;

113

114

// Assuming decoded AVFrame is available

115

AVFrame srcFrame = /* decoded frame */;

116

AVFrame dstFrame = av_frame_alloc();

117

118

// Allocate destination frame with same properties

119

av_frame_copy_props(dstFrame, srcFrame);

120

dstFrame.format(srcFrame.format());

121

dstFrame.width(srcFrame.width());

122

dstFrame.height(srcFrame.height());

123

av_frame_get_buffer(dstFrame, 32);

124

125

// Set up post-processing

126

pp_context context = pp_get_context(srcFrame.width(), srcFrame.height(), PP_CPU_CAPS_AUTO);

127

pp_mode mode = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a", 4);

128

129

try {

130

// Apply post-processing

131

pp_postprocess(srcFrame.data(), srcFrame.linesize(),

132

dstFrame.data(), dstFrame.linesize(),

133

srcFrame.width(), srcFrame.height(),

134

null, 0, // No quantization data

135

mode, context, 0);

136

137

// dstFrame now contains post-processed video

138

139

} finally {

140

pp_free_mode(mode);

141

pp_free_context(context);

142

av_frame_free(dstFrame);

143

}

144

```

145

146

## Post-Processing Filter Types

147

148

### Available Filter Modes

149

150

The mode string can contain combinations of the following filters:

151

152

- **`hb`** - Horizontal deblocking filter

153

- **`vb`** - Vertical deblocking filter

154

- **`dr`** - Deringing filter (reduces ringing artifacts)

155

- **`tn`** - Temporal noise reduction

156

- **`al`** - Automatic luminance correction

157

- **`fd`** - Force deblocking (stronger than hb/vb)

158

159

### Quality Modifiers

160

161

Each filter can be modified with quality indicators:

162

- **`a`** - Automatic quality (recommended)

163

- **`c`** - Chrominance processing

164

- **`y`** - Luminance processing only

165

166

### Common Mode Combinations

167

168

```java

169

// Basic deblocking

170

pp_mode basic = pp_get_mode_by_name_and_quality("hb,vb", 3);

171

172

// Comprehensive filtering

173

pp_mode comprehensive = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a", 5);

174

175

// Noise reduction focused

176

pp_mode denoising = pp_get_mode_by_name_and_quality("tn:64:128:256", 4);

177

178

// Maximum quality processing

179

pp_mode maxQuality = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a,al", PP_QUALITY_MAX);

180

```

181

182

## CPU Optimization Flags

183

184

```java { .api }

185

// CPU capability constants for context creation

186

int PP_CPU_CAPS_MMX = 0x80000000; // MMX instructions

187

int PP_CPU_CAPS_MMX2 = 0x20000000; // MMX2 instructions

188

int PP_CPU_CAPS_3DNOW = 0x40000000; // 3DNow! instructions

189

int PP_CPU_CAPS_ALTIVEC = 0x10000000; // AltiVec instructions

190

int PP_CPU_CAPS_AUTO = 0x00080000; // Auto-detect capabilities

191

```

192

193

## Library Information

194

195

```java { .api }

196

/**

197

* Get libpostproc version information

198

* @return Version number as integer

199

*/

200

int postproc_version();

201

202

/**

203

* Get build configuration string

204

* @return Configuration details

205

*/

206

BytePointer postproc_configuration();

207

208

/**

209

* Get library license information

210

* @return License text

211

*/

212

BytePointer postproc_license();

213

```

214

215

## Constants and Limits

216

217

```java { .api }

218

int PP_QUALITY_MAX = 6; // Maximum quality level for processing modes

219

```

220

221

## Memory Management

222

223

Post-processing contexts and modes must be explicitly freed:

224

225

```java

226

// Always pair allocation with deallocation

227

pp_context context = pp_get_context(width, height, flags);

228

pp_mode mode = pp_get_mode_by_name_and_quality(modeString, quality);

229

230

try {

231

// Use context and mode

232

} finally {

233

pp_free_mode(mode); // Free mode first

234

pp_free_context(context); // Then free context

235

}

236

```

237

238

## Integration with Decoder Pipeline

239

240

Post-processing is typically applied after video decoding:

241

242

```java

243

// 1. Decode frame

244

AVFrame decodedFrame = /* from decoder */;

245

246

// 2. Create post-processing context

247

pp_context ppContext = pp_get_context(

248

decodedFrame.width(), decodedFrame.height(), PP_CPU_CAPS_AUTO);

249

pp_mode ppMode = pp_get_mode_by_name_and_quality("hb:a,vb:a,dr:a", 4);

250

251

// 3. Allocate output frame

252

AVFrame enhancedFrame = av_frame_alloc();

253

av_frame_copy_props(enhancedFrame, decodedFrame);

254

enhancedFrame.format(decodedFrame.format());

255

enhancedFrame.width(decodedFrame.width());

256

enhancedFrame.height(decodedFrame.height());

257

av_frame_get_buffer(enhancedFrame, 32);

258

259

// 4. Apply post-processing

260

pp_postprocess(decodedFrame.data(), decodedFrame.linesize(),

261

enhancedFrame.data(), enhancedFrame.linesize(),

262

decodedFrame.width(), decodedFrame.height(),

263

null, 0, ppMode, ppContext, 0);

264

265

// 5. Use enhanced frame for display or further processing

266

```