History

avcodec/codec_internal: Add FFCodec, hide internal part of AVCodec

Up until now, codec.h contains both public and private parts of AVCodec. This exposes the internals of AVCodec to users and leads them into the temptation of actually using them and forces us to forward-declare structures and types that users can't use at all. This commit changes this by adding a new structure FFCodec to codec_internal.h that extends AVCodec, i.e. contains the public AVCodec as first member; the private fields of AVCodec are moved to this structure, leaving codec.h clean.

Andreas Rheinhardt committed 4 years ago

Commit 20f97271 parent a688f3c513 files · +5330 −5260Browse files

Showing the changes to libavcodec/codec.h (1 of 513 files). Show all

Unified · Split

libavcodec/codec.h+0−121
@@ -190,12 +190,6 @@ typedef struct AVProfile { · 189 unmodified lines
190 const char *name; ///< short name for the profile190 const char *name; ///< short name for the profile
191} AVProfile;191} AVProfile;
192 192
193typedef struct AVCodecDefault AVCodecDefault;
194
195struct AVCodecContext;
196struct AVSubtitle;
197struct AVPacket;
198
199/**193/**
200 * AVCodec.194 * AVCodec.
201 */195 */
@@ -250,121 +244,6 @@ typedef struct AVCodec { · 48 unmodified lines
250 * Array of supported channel layouts, terminated with a zeroed layout.244 * Array of supported channel layouts, terminated with a zeroed layout.
251 */245 */
252 const AVChannelLayout *ch_layouts;246 const AVChannelLayout *ch_layouts;
253
254 /*****************************************************************
255 * No fields below this line are part of the public API. They
256 * may not be used outside of libavcodec and can be changed and
257 * removed at will.
258 * New public fields should be added right above.
259 *****************************************************************
260 */
261 /**
262 * Internal codec capabilities.
263 * See FF_CODEC_CAP_* in internal.h
264 */
265 int caps_internal;
266
267 int priv_data_size;
268 /**
269 * @name Frame-level threading support functions
270 * @{
271 */
272 /**
273 * Copy necessary context variables from a previous thread context to the current one.
274 * If not defined, the next thread will start automatically; otherwise, the codec
275 * must call ff_thread_finish_setup().
276 *
277 * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
278 */
279 int (*update_thread_context)(struct AVCodecContext *dst, const struct AVCodecContext *src);
280
281 /**
282 * Copy variables back to the user-facing context
283 */
284 int (*update_thread_context_for_user)(struct AVCodecContext *dst, const struct AVCodecContext *src);
285 /** @} */
286
287 /**
288 * Private codec-specific defaults.
289 */
290 const AVCodecDefault *defaults;
291
292 /**
293 * Initialize codec static data, called from av_codec_iterate().
294 *
295 * This is not intended for time consuming operations as it is
296 * run for every codec regardless of that codec being used.
297 */
298 void (*init_static_data)(struct AVCodec *codec);
299
300 int (*init)(struct AVCodecContext *);
301 int (*encode_sub)(struct AVCodecContext *, uint8_t *buf, int buf_size,
302 const struct AVSubtitle *sub);
303 /**
304 * Encode data to an AVPacket.
305 *
306 * @param avctx codec context
307 * @param avpkt output AVPacket
308 * @param[in] frame AVFrame containing the raw data to be encoded
309 * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
310 * non-empty packet was returned in avpkt.
311 * @return 0 on success, negative error code on failure
312 */
313 int (*encode2)(struct AVCodecContext *avctx, struct AVPacket *avpkt,
314 const struct AVFrame *frame, int *got_packet_ptr);
315 /**
316 * Decode picture or subtitle data.
317 *
318 * @param avctx codec context
319 * @param outdata codec type dependent output struct
320 * @param[out] got_frame_ptr decoder sets to 0 or 1 to indicate that a
321 * non-empty frame or subtitle was returned in
322 * outdata.
323 * @param[in] avpkt AVPacket containing the data to be decoded
324 * @return amount of bytes read from the packet on success, negative error
325 * code on failure
326 */
327 int (*decode)(struct AVCodecContext *avctx, void *outdata,
328 int *got_frame_ptr, struct AVPacket *avpkt);
329 int (*close)(struct AVCodecContext *);
330 /**
331 * Encode API with decoupled frame/packet dataflow. This function is called
332 * to get one output packet. It should call ff_encode_get_frame() to obtain
333 * input data.
334 */
335 int (*receive_packet)(struct AVCodecContext *avctx, struct AVPacket *avpkt);
336
337 /**
338 * Decode API with decoupled packet/frame dataflow. This function is called
339 * to get one output frame. It should call ff_decode_get_packet() to obtain
340 * input data.
341 */
342 int (*receive_frame)(struct AVCodecContext *avctx, struct AVFrame *frame);
343 /**
344 * Flush buffers.
345 * Will be called when seeking
346 */
347 void (*flush)(struct AVCodecContext *);
348
349 /**
350 * Decoding only, a comma-separated list of bitstream filters to apply to
351 * packets before decoding.
352 */
353 const char *bsfs;
354
355 /**
356 * Array of pointers to hardware configurations supported by the codec,
357 * or NULL if no hardware supported. The array is terminated by a NULL
358 * pointer.
359 *
360 * The user can only access this field via avcodec_get_hw_config().
361 */
362 const struct AVCodecHWConfigInternal *const *hw_configs;
363
364 /**
365 * List of supported codec_tags, terminated by FF_CODEC_TAGS_END.
366 */
367 const uint32_t *codec_tags;
368} AVCodec;247} AVCodec;
369 248
370/**249/**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t