node-av 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +51 -38
  2. package/dist/api/bitstream-filter.d.ts +180 -123
  3. package/dist/api/bitstream-filter.js +180 -125
  4. package/dist/api/bitstream-filter.js.map +1 -1
  5. package/dist/api/decoder.d.ts +279 -132
  6. package/dist/api/decoder.js +285 -142
  7. package/dist/api/decoder.js.map +1 -1
  8. package/dist/api/encoder.d.ts +246 -162
  9. package/dist/api/encoder.js +272 -208
  10. package/dist/api/encoder.js.map +1 -1
  11. package/dist/api/filter-presets.d.ts +690 -94
  12. package/dist/api/filter-presets.js +686 -102
  13. package/dist/api/filter-presets.js.map +1 -1
  14. package/dist/api/filter.d.ts +249 -213
  15. package/dist/api/filter.js +252 -242
  16. package/dist/api/filter.js.map +1 -1
  17. package/dist/api/hardware.d.ts +224 -117
  18. package/dist/api/hardware.js +380 -214
  19. package/dist/api/hardware.js.map +1 -1
  20. package/dist/api/index.d.ts +3 -3
  21. package/dist/api/index.js +1 -1
  22. package/dist/api/index.js.map +1 -1
  23. package/dist/api/io-stream.d.ts +65 -61
  24. package/dist/api/io-stream.js +43 -46
  25. package/dist/api/io-stream.js.map +1 -1
  26. package/dist/api/media-input.d.ts +242 -140
  27. package/dist/api/media-input.js +205 -103
  28. package/dist/api/media-input.js.map +1 -1
  29. package/dist/api/media-output.d.ts +206 -128
  30. package/dist/api/media-output.js +210 -128
  31. package/dist/api/media-output.js.map +1 -1
  32. package/dist/api/pipeline.d.ts +168 -38
  33. package/dist/api/pipeline.js +238 -14
  34. package/dist/api/pipeline.js.map +1 -1
  35. package/dist/api/types.d.ts +21 -187
  36. package/dist/api/utils.d.ts +1 -2
  37. package/dist/api/utils.js +9 -0
  38. package/dist/api/utils.js.map +1 -1
  39. package/dist/lib/audio-fifo.d.ts +127 -170
  40. package/dist/lib/audio-fifo.js +130 -173
  41. package/dist/lib/audio-fifo.js.map +1 -1
  42. package/dist/lib/binding.js +5 -0
  43. package/dist/lib/binding.js.map +1 -1
  44. package/dist/lib/bitstream-filter-context.d.ts +139 -184
  45. package/dist/lib/bitstream-filter-context.js +139 -188
  46. package/dist/lib/bitstream-filter-context.js.map +1 -1
  47. package/dist/lib/bitstream-filter.d.ts +68 -54
  48. package/dist/lib/bitstream-filter.js +68 -54
  49. package/dist/lib/bitstream-filter.js.map +1 -1
  50. package/dist/lib/codec-context.d.ts +316 -380
  51. package/dist/lib/codec-context.js +316 -381
  52. package/dist/lib/codec-context.js.map +1 -1
  53. package/dist/lib/codec-parameters.d.ts +160 -170
  54. package/dist/lib/codec-parameters.js +162 -172
  55. package/dist/lib/codec-parameters.js.map +1 -1
  56. package/dist/lib/codec-parser.d.ts +91 -104
  57. package/dist/lib/codec-parser.js +92 -103
  58. package/dist/lib/codec-parser.js.map +1 -1
  59. package/dist/lib/codec.d.ts +264 -281
  60. package/dist/lib/codec.js +268 -285
  61. package/dist/lib/codec.js.map +1 -1
  62. package/dist/lib/dictionary.d.ts +149 -203
  63. package/dist/lib/dictionary.js +158 -212
  64. package/dist/lib/dictionary.js.map +1 -1
  65. package/dist/lib/error.d.ts +96 -130
  66. package/dist/lib/error.js +98 -128
  67. package/dist/lib/error.js.map +1 -1
  68. package/dist/lib/filter-context.d.ts +284 -218
  69. package/dist/lib/filter-context.js +290 -227
  70. package/dist/lib/filter-context.js.map +1 -1
  71. package/dist/lib/filter-graph.d.ts +251 -292
  72. package/dist/lib/filter-graph.js +253 -294
  73. package/dist/lib/filter-graph.js.map +1 -1
  74. package/dist/lib/filter-inout.d.ts +87 -95
  75. package/dist/lib/filter-inout.js +87 -95
  76. package/dist/lib/filter-inout.js.map +1 -1
  77. package/dist/lib/filter.d.ts +93 -111
  78. package/dist/lib/filter.js +93 -111
  79. package/dist/lib/filter.js.map +1 -1
  80. package/dist/lib/format-context.d.ts +320 -428
  81. package/dist/lib/format-context.js +313 -385
  82. package/dist/lib/format-context.js.map +1 -1
  83. package/dist/lib/frame.d.ts +262 -405
  84. package/dist/lib/frame.js +263 -408
  85. package/dist/lib/frame.js.map +1 -1
  86. package/dist/lib/hardware-device-context.d.ts +149 -203
  87. package/dist/lib/hardware-device-context.js +149 -203
  88. package/dist/lib/hardware-device-context.js.map +1 -1
  89. package/dist/lib/hardware-frames-context.d.ts +170 -180
  90. package/dist/lib/hardware-frames-context.js +171 -181
  91. package/dist/lib/hardware-frames-context.js.map +1 -1
  92. package/dist/lib/index.d.ts +2 -1
  93. package/dist/lib/index.js +2 -2
  94. package/dist/lib/index.js.map +1 -1
  95. package/dist/lib/input-format.d.ts +89 -117
  96. package/dist/lib/input-format.js +89 -117
  97. package/dist/lib/input-format.js.map +1 -1
  98. package/dist/lib/io-context.d.ts +209 -241
  99. package/dist/lib/io-context.js +220 -252
  100. package/dist/lib/io-context.js.map +1 -1
  101. package/dist/lib/log.d.ts +85 -119
  102. package/dist/lib/log.js +85 -122
  103. package/dist/lib/log.js.map +1 -1
  104. package/dist/lib/native-types.d.ts +117 -106
  105. package/dist/lib/native-types.js +0 -7
  106. package/dist/lib/native-types.js.map +1 -1
  107. package/dist/lib/option.d.ts +284 -241
  108. package/dist/lib/option.js +309 -249
  109. package/dist/lib/option.js.map +1 -1
  110. package/dist/lib/output-format.d.ts +77 -101
  111. package/dist/lib/output-format.js +77 -101
  112. package/dist/lib/output-format.js.map +1 -1
  113. package/dist/lib/packet.d.ts +172 -240
  114. package/dist/lib/packet.js +172 -241
  115. package/dist/lib/packet.js.map +1 -1
  116. package/dist/lib/rational.d.ts +0 -2
  117. package/dist/lib/rational.js +0 -2
  118. package/dist/lib/rational.js.map +1 -1
  119. package/dist/lib/software-resample-context.d.ts +241 -325
  120. package/dist/lib/software-resample-context.js +242 -326
  121. package/dist/lib/software-resample-context.js.map +1 -1
  122. package/dist/lib/software-scale-context.d.ts +129 -173
  123. package/dist/lib/software-scale-context.js +131 -175
  124. package/dist/lib/software-scale-context.js.map +1 -1
  125. package/dist/lib/stream.d.ts +87 -197
  126. package/dist/lib/stream.js +87 -197
  127. package/dist/lib/stream.js.map +1 -1
  128. package/dist/lib/utilities.d.ts +372 -181
  129. package/dist/lib/utilities.js +373 -182
  130. package/dist/lib/utilities.js.map +1 -1
  131. package/install/check.js +0 -1
  132. package/package.json +21 -12
  133. package/release_notes.md +43 -59
  134. package/CHANGELOG.md +0 -8
@@ -1 +1 @@
1
- {"version":3,"file":"software-resample-context.js","sourceRoot":"","sources":["../../src/lib/software-resample-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,OAAO,uBAAwB,SAAQ,YAA2C;IACtF;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH;QACE,KAAK,CAAC,IAAI,QAAQ,CAAC,uBAAuB,EAAE,CAAC,CAAC;IAChD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACH,aAAa,CACX,WAA0B,EAC1B,YAA4B,EAC5B,aAAqB,EACrB,UAAyB,EACzB,WAA2B,EAC3B,YAAoB;QAEpB,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IACpH,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI;QACF,IAAI,CAAC,MAAM,CAAC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B,CAAC,UAAoB;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS,CAAC,MAAgB,EAAE,MAAc;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,aAAa,CAAC,KAAa;QACzB,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAChC,CAAC;CACF"}
@@ -3,288 +3,244 @@ import type { AVPixelFormat, SWSFlag } from '../constants/constants.js';
3
3
  import type { Frame } from './frame.js';
4
4
  import type { NativeSoftwareScaleContext, NativeWrapper } from './native-types.js';
5
5
  /**
6
- * Software video scaling context.
6
+ * Video scaling and pixel format conversion context.
7
7
  *
8
- * Provides high-quality video scaling, format conversion, and color space conversion.
8
+ * Provides high-quality image scaling and pixel format conversion for video frames.
9
9
  * Supports various scaling algorithms from fast bilinear to high-quality Lanczos.
10
- * Uses the libswscale library for efficient video processing.
10
+ * Essential for resolution changes, aspect ratio adjustments, and format compatibility
11
+ * in video processing pipelines.
11
12
  *
12
13
  * Direct mapping to FFmpeg's SwsContext.
13
14
  *
14
15
  * @example
15
16
  * ```typescript
16
17
  * import { SoftwareScaleContext, Frame, FFmpegError } from 'node-av';
17
- * import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24, SWS_BILINEAR } from 'node-av/constants';
18
+ * import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24, SWS_LANCZOS } from 'node-av/constants';
18
19
  *
19
- * // Create and configure scale context
20
- * const sws = new SoftwareScaleContext();
21
- * sws.getContext(
22
- * 1920, 1080, AV_PIX_FMT_YUV420P,
23
- * 1280, 720, AV_PIX_FMT_RGB24,
24
- * SWS_BILINEAR
25
- * );
20
+ * // Create scaler
21
+ * const scaler = new SoftwareScaleContext();
26
22
  *
27
- * // Scale frame data
28
- * const ret = await sws.scale(
29
- * srcSlice, srcStride, 0, srcHeight,
30
- * dst, dstStride
23
+ * // Configure scaling: 1920x1080 YUV420P -> 1280x720 RGB24
24
+ * scaler.getContext(
25
+ * 1920, 1080, AV_PIX_FMT_YUV420P, // Source
26
+ * 1280, 720, AV_PIX_FMT_RGB24, // Destination
27
+ * SWS_LANCZOS // High quality
31
28
  * );
32
29
  *
33
- * // Or scale Frame objects directly
34
- * const scaleRet = await sws.scaleFrame(dstFrame, srcFrame);
35
- * FFmpegError.throwIfError(scaleRet, 'scaleFrame');
30
+ * const ret = scaler.initContext();
31
+ * FFmpegError.throwIfError(ret, 'initContext');
32
+ *
33
+ * // Scale frames
34
+ * const dstFrame = new Frame();
35
+ * dstFrame.width = 1280;
36
+ * dstFrame.height = 720;
37
+ * dstFrame.format = AV_PIX_FMT_RGB24;
38
+ * dstFrame.allocBuffer();
39
+ *
40
+ * const height = await scaler.scaleFrame(dstFrame, srcFrame);
41
+ * console.log(`Scaled to ${height} lines`);
36
42
  *
37
- * // Cleanup
38
- * sws.freeContext();
43
+ * // Clean up
44
+ * scaler.freeContext();
39
45
  * ```
46
+ *
47
+ * @see [SwsContext](https://ffmpeg.org/doxygen/trunk/structSwsContext.html) - FFmpeg Doxygen
48
+ * @see {@link Frame} For video frame operations
40
49
  */
41
50
  export declare class SoftwareScaleContext extends OptionMember<NativeSoftwareScaleContext> implements Disposable, NativeWrapper<NativeSoftwareScaleContext> {
42
- /**
43
- * Create a new software scale context.
44
- *
45
- * The context is uninitialized - you must call allocContext() or getContext() before use.
46
- * No FFmpeg resources are allocated until initialization.
47
- *
48
- * Direct wrapper around SwsContext.
49
- *
50
- * @example
51
- * ```typescript
52
- * import { SoftwareScaleContext } from 'node-av';
53
- * import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24, SWS_BILINEAR } from 'node-av/constants';
54
- *
55
- * const sws = new SoftwareScaleContext();
56
- * sws.getContext(
57
- * 1920, 1080, AV_PIX_FMT_YUV420P,
58
- * 1280, 720, AV_PIX_FMT_RGB24,
59
- * SWS_BILINEAR
60
- * );
61
- * ```
62
- */
63
51
  constructor();
64
52
  /**
65
- * Allocate an empty SwsContext.
53
+ * Allocate scale context.
66
54
  *
67
- * Allocates an uninitialized scale context.
68
- * Options must be set through the AVOptions API before calling initContext().
55
+ * Allocates memory for the scaler.
56
+ * Must be called before configuration if using options.
69
57
  *
70
- * Direct mapping to sws_alloc_context()
71
- *
72
- * @throws {Error} Memory allocation failure (ENOMEM)
58
+ * Direct mapping to sws_alloc_context().
73
59
  *
74
60
  * @example
75
61
  * ```typescript
76
- * import { SoftwareScaleContext, FFmpegError } from 'node-av';
77
- *
78
- * const sws = new SoftwareScaleContext();
79
- * sws.allocContext();
80
- * // Set options via AVOptions API
81
- * const ret = sws.initContext();
82
- * FFmpegError.throwIfError(ret, 'initContext');
62
+ * const scaler = new SoftwareScaleContext();
63
+ * scaler.allocContext();
64
+ * // Now configure with setOption() or getContext()
83
65
  * ```
84
66
  *
85
- * @see {@link getContext} For one-step allocation and configuration
86
- * @see {@link initContext} To initialize after configuration
67
+ * @see {@link getContext} For direct configuration
87
68
  */
88
69
  allocContext(): void;
89
70
  /**
90
- * Allocate and return an SwsContext.
91
- *
92
- * One-step allocation and configuration of the scale context.
93
- * Sets up everything needed for scaling operations.
94
- *
95
- * Direct mapping to sws_getContext()
96
- *
97
- * @param srcW - The width of the source image
98
- * @param srcH - The height of the source image
99
- * @param srcFormat - The source image format
100
- * @param dstW - The width of the destination image
101
- * @param dstH - The height of the destination image
102
- * @param dstFormat - The destination image format
103
- * @param flags - Specify which algorithm and options to use for rescaling:
104
- * - SWS_FAST_BILINEAR: Fast bilinear
105
- * - SWS_BILINEAR: Bilinear
106
- * - SWS_BICUBIC: Bicubic
107
- * - SWS_X: Experimental
108
- * - SWS_POINT: Nearest neighbor
109
- * - SWS_AREA: Area averaging
110
- * - SWS_BICUBLIN: Luma bicubic, chroma bilinear
111
- * - SWS_GAUSS: Gaussian
112
- * - SWS_SINC: Sinc
113
- * - SWS_LANCZOS: Lanczos
114
- * - SWS_SPLINE: Natural bicubic spline
115
- *
116
- * @throws {Error} Memory allocation failure (ENOMEM)
71
+ * Configure scaling context.
72
+ *
73
+ * Sets up the scaler with source and destination formats.
74
+ * This is the primary configuration method.
75
+ *
76
+ * Direct mapping to sws_getContext().
77
+ *
78
+ * @param srcW - Source width in pixels
79
+ * @param srcH - Source height in pixels
80
+ * @param srcFormat - Source pixel format
81
+ * @param dstW - Destination width in pixels
82
+ * @param dstH - Destination height in pixels
83
+ * @param dstFormat - Destination pixel format
84
+ * @param flags - Scaling algorithm flags (SWS_*)
117
85
  *
118
86
  * @example
119
87
  * ```typescript
120
- * import { SoftwareScaleContext } from 'node-av';
121
- * import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24, SWS_BILINEAR } from 'node-av/constants';
88
+ * import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24 } from 'node-av/constants';
89
+ * import { SWS_BILINEAR, SWS_BICUBIC, SWS_LANCZOS, SWS_FAST_BILINEAR } from 'node-av/constants';
122
90
  *
123
- * // Scale from 1080p YUV to 720p RGB
124
- * sws.getContext(
91
+ * // Fast bilinear (lower quality, faster)
92
+ * scaler.getContext(
125
93
  * 1920, 1080, AV_PIX_FMT_YUV420P,
126
94
  * 1280, 720, AV_PIX_FMT_RGB24,
127
- * SWS_BILINEAR
95
+ * SWS_FAST_BILINEAR
96
+ * );
97
+ *
98
+ * // High quality Lanczos (higher quality, slower)
99
+ * scaler.getContext(
100
+ * 1920, 1080, AV_PIX_FMT_YUV420P,
101
+ * 3840, 2160, AV_PIX_FMT_YUV420P, // Upscaling
102
+ * SWS_LANCZOS
128
103
  * );
129
104
  * ```
130
105
  *
131
- * @see {@link scale} To scale image data
132
- * @see {@link scaleFrame} To scale Frame objects
106
+ * @see {@link initContext} Must be called after configuration
133
107
  */
134
108
  getContext(srcW: number, srcH: number, srcFormat: AVPixelFormat, dstW: number, dstH: number, dstFormat: AVPixelFormat, flags?: SWSFlag): void;
135
109
  /**
136
- * Initialize the swscaler context sws_context.
110
+ * Initialize scaling context.
137
111
  *
138
- * Completes initialization of the scale context.
139
- * Must be called after allocContext() and configuration.
112
+ * Initializes the scaler after configuration.
113
+ * Must be called before any scaling operations.
140
114
  *
141
- * Direct mapping to sws_init_context()
115
+ * Direct mapping to sws_init_context().
142
116
  *
143
117
  * @returns 0 on success, negative AVERROR on error:
144
- * - 0: Success
145
- * - AVERROR(EINVAL): Invalid parameters
146
- * - AVERROR(ENOMEM): Memory allocation failure
147
- * - <0: Other errors
118
+ * - AVERROR_EINVAL: Invalid parameters
119
+ * - AVERROR_ENOMEM: Memory allocation failure
148
120
  *
149
121
  * @example
150
122
  * ```typescript
151
123
  * import { FFmpegError } from 'node-av';
152
124
  *
153
- * const ret = sws.initContext();
125
+ * const ret = scaler.initContext();
154
126
  * FFmpegError.throwIfError(ret, 'initContext');
155
127
  * ```
156
128
  *
157
- * @see {@link allocContext} For allocation
158
- * @see {@link getContext} For one-step setup
129
+ * @see {@link getContext} For configuration
159
130
  */
160
131
  initContext(): number;
161
132
  /**
162
- * Free the swscaler context swsContext.
133
+ * Free scaling context.
163
134
  *
164
- * Releases all resources associated with the scale context.
165
- * Safe to call on NULL context.
135
+ * Releases all resources associated with the scaler.
136
+ * The context becomes invalid after calling this.
166
137
  *
167
- * Direct mapping to sws_freeContext()
138
+ * Direct mapping to sws_freeContext().
168
139
  *
169
140
  * @example
170
141
  * ```typescript
171
- * sws.freeContext();
172
- * // sws is now invalid and should not be used
142
+ * scaler.freeContext();
143
+ * // Scaler is now invalid
173
144
  * ```
145
+ *
146
+ * @see {@link Symbol.dispose} For automatic cleanup
174
147
  */
175
148
  freeContext(): void;
176
149
  /**
177
- * Scale the image slice in srcSlice and put the resulting scaled slice in the image in dst.
178
- *
179
- * Scales image data from source to destination.
180
- * Processes image in slices for efficient memory usage.
150
+ * Scale image data.
181
151
  *
182
- * Direct mapping to sws_scale()
152
+ * Scales raw image data from source to destination buffers.
153
+ * Low-level interface for custom buffer management.
183
154
  *
184
- * @param srcSlice - The array containing the pointers to the planes of the source slice
185
- * @param srcStride - The array containing the strides for each plane of the source image
186
- * @param srcSliceY - The position in the source image of the slice to process (first row number)
187
- * @param srcSliceH - The height of the source slice (number of rows)
188
- * @param dst - The array containing the pointers to the planes of the destination image
189
- * @param dstStride - The array containing the strides for each plane of the destination image
155
+ * Direct mapping to sws_scale().
190
156
  *
191
- * @returns Promise resolving to the height of the output slice
157
+ * @param srcSlice - Source data planes (one buffer per plane)
158
+ * @param srcStride - Bytes per line for each plane
159
+ * @param srcSliceY - Starting Y position in source
160
+ * @param srcSliceH - Height of source slice to process
161
+ * @param dst - Destination data planes
162
+ * @param dstStride - Destination bytes per line
163
+ * @returns Output height in pixels, negative AVERROR on error:
164
+ * - AVERROR_EINVAL: Invalid parameters
192
165
  *
193
166
  * @example
194
167
  * ```typescript
195
- * const outputHeight = await sws.scale(
196
- * srcData,
197
- * srcLinesize,
198
- * 0,
199
- * srcHeight,
200
- * dstData,
201
- * dstLinesize
168
+ * // Scale YUV420P data
169
+ * const srcPlanes = [yPlane, uPlane, vPlane];
170
+ * const srcStrides = [1920, 960, 960]; // Full HD
171
+ * const dstPlanes = [dstY, dstU, dstV];
172
+ * const dstStrides = [1280, 640, 640]; // 720p
173
+ *
174
+ * const height = await scaler.scale(
175
+ * srcPlanes, srcStrides, 0, 1080,
176
+ * dstPlanes, dstStrides
202
177
  * );
203
- * console.log(`Scaled ${outputHeight} rows`);
178
+ * console.log(`Scaled ${height} lines`);
204
179
  * ```
205
180
  *
206
- * @see {@link scaleFrame} For Frame-based scaling
207
- *
208
- * @note Slices must be provided in sequential order (top-bottom or bottom-top).
209
- * Non-sequential order results in undefined behavior.
181
+ * @see {@link scaleFrame} For frame-based scaling
210
182
  */
211
183
  scale(srcSlice: Buffer[], srcStride: number[], srcSliceY: number, srcSliceH: number, dst: Buffer[], dstStride: number[]): Promise<number>;
212
184
  /**
213
- * Scale source data from src and write the output to dst.
214
- *
215
- * Frame-based scaling with automatic configuration.
216
- * Dynamically adapts to frame properties without reallocation.
185
+ * Scale video frame.
217
186
  *
218
- * Direct mapping to sws_scale_frame()
187
+ * Scales an entire video frame to the destination format.
188
+ * Simpler interface than scale() for frame-based processing.
219
189
  *
220
- * @param dst - The destination frame (buffers can be pre-allocated or allocated by scaler)
221
- * @param src - The source frame
190
+ * Direct mapping to sws_scale_frame().
222
191
  *
223
- * @returns The height of the output slice on success, negative AVERROR on error:
224
- * - >0: Output height (success)
225
- * - AVERROR(EINVAL): Invalid parameters
226
- * - AVERROR(ENOMEM): Memory allocation failure
227
- * - <0: Other errors
192
+ * @param dst - Destination frame (must be allocated)
193
+ * @param src - Source frame
194
+ * @returns 0 on success, negative AVERROR on error:
195
+ * - AVERROR_EINVAL: Invalid parameters
196
+ * - AVERROR_ENOMEM: Memory allocation failure
228
197
  *
229
198
  * @example
230
199
  * ```typescript
231
200
  * import { Frame, FFmpegError } from 'node-av';
232
201
  * import { AV_PIX_FMT_RGB24 } from 'node-av/constants';
233
202
  *
234
- * const srcFrame = new Frame();
235
- * srcFrame.alloc();
236
- * // ... fill srcFrame with data ...
237
- *
203
+ * // Create destination frame
238
204
  * const dstFrame = new Frame();
239
- * dstFrame.alloc();
240
205
  * dstFrame.width = 1280;
241
206
  * dstFrame.height = 720;
242
207
  * dstFrame.format = AV_PIX_FMT_RGB24;
243
- * const bufRet = dstFrame.getBuffer();
244
- * FFmpegError.throwIfError(bufRet, 'getBuffer');
208
+ * const ret = dstFrame.allocBuffer();
209
+ * FFmpegError.throwIfError(ret, 'allocBuffer');
210
+ *
211
+ * // Scale frame
212
+ * const ret2 = await scaler.scaleFrame(dstFrame, srcFrame);
213
+ * FFmpegError.throwIfError(ret2, 'scaleFrame');
245
214
  *
246
- * const ret = await sws.scaleFrame(dstFrame, srcFrame);
247
- * FFmpegError.throwIfError(ret, 'scaleFrame');
248
- * console.log(`Scaled to height: ${ret}`);
215
+ * // dstFrame now contains scaled image
249
216
  * ```
250
217
  *
251
218
  * @see {@link scale} For buffer-based scaling
252
- *
253
- * @note This function can be used directly on an allocated context without
254
- * calling sws_init_context(). Such usage is fully dynamic and does not
255
- * require reallocation if frame properties change.
256
219
  */
257
220
  scaleFrame(dst: Frame, src: Frame): Promise<number>;
258
221
  /**
259
- * Get the native FFmpeg SwsContext pointer.
222
+ * Get the underlying native SoftwareScaleContext object.
223
+ *
224
+ * @returns The native SoftwareScaleContext binding object
260
225
  *
261
- * @internal For use by other wrapper classes
262
- * @returns The underlying native scale context object
226
+ * @internal
263
227
  */
264
228
  getNative(): NativeSoftwareScaleContext;
265
229
  /**
266
- * Dispose of the scale context.
230
+ * Dispose of the scaling context.
267
231
  *
268
232
  * Implements the Disposable interface for automatic cleanup.
269
233
  * Equivalent to calling freeContext().
270
234
  *
271
235
  * @example
272
236
  * ```typescript
273
- * import { SoftwareScaleContext } from 'node-av';
274
- * import { AV_PIX_FMT_YUV420P, AV_PIX_FMT_RGB24, SWS_BILINEAR } from 'node-av/constants';
275
- *
276
237
  * {
277
- * using sws = new SoftwareScaleContext();
278
- * sws.getContext(
279
- * 1920, 1080, AV_PIX_FMT_YUV420P,
280
- * 1280, 720, AV_PIX_FMT_RGB24,
281
- * SWS_BILINEAR
282
- * );
283
- * // ... use context
238
+ * using scaler = new SoftwareScaleContext();
239
+ * scaler.getContext(...);
240
+ * scaler.initContext();
241
+ * // Use scaler...
284
242
  * } // Automatically freed when leaving scope
285
243
  * ```
286
- *
287
- * @see {@link freeContext} For manual cleanup
288
244
  */
289
245
  [Symbol.dispose](): void;
290
246
  }