The goal is to distinguish between APIs provided by the generic layer to individual codecs and APIs internal to the generic layer. Start by moving ff_{decode,encode}_receive_frame() and ff_{decode,encode}_preinit() into this new header, as those functions are called from generic code and should not be visible to individual codecs.
Unified · Split
| @@ -34,6 +34,7 @@ · 33 unmodified lines | |||
| 34 | #include "libavutil/opt.h" | 34 | #include "libavutil/opt.h" |
| 35 | #include "libavutil/thread.h" | 35 | #include "libavutil/thread.h" |
| 36 | #include "avcodec.h" | 36 | #include "avcodec.h" |
| 37 | #include "avcodec_internal.h" | ||
| 37 | #include "bsf.h" | 38 | #include "bsf.h" |
| 38 | #include "codec_internal.h" | 39 | #include "codec_internal.h" |
| 39 | #include "decode.h" | 40 | #include "decode.h" |
| @@ -0,0 +1,53 @@ | |||
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU Lesser General Public | ||
| 6 | * License as published by the Free Software Foundation; either | ||
| 7 | * version 2.1 of the License, or (at your option) any later version. | ||
| 8 | * | ||
| 9 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 12 | * Lesser General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU Lesser General Public | ||
| 15 | * License along with FFmpeg; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | |||
| 19 | /* | ||
| 20 | * APIs internal to the generic codec layer. | ||
| 21 | * | ||
| 22 | * MUST NOT be included by individual encoders or decoders. | ||
| 23 | */ | ||
| 24 | |||
| 25 | #ifndef AVCODEC_AVCODEC_INTERNAL_H | ||
| 26 | #define AVCODEC_AVCODEC_INTERNAL_H | ||
| 27 | |||
| 28 | struct AVCodecContext; | ||
| 29 | struct AVFrame; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * avcodec_receive_frame() implementation for decoders. | ||
| 33 | */ | ||
| 34 | int ff_decode_receive_frame(struct AVCodecContext *avctx, struct AVFrame *frame); | ||
| 35 | |||
| 36 | /** | ||
| 37 | * avcodec_receive_frame() implementation for encoders. | ||
| 38 | */ | ||
| 39 | int ff_encode_receive_frame(struct AVCodecContext *avctx, struct AVFrame *frame); | ||
| 40 | |||
| 41 | /* | ||
| 42 | * Perform encoder initialization and validation. | ||
| 43 | * Called when opening the encoder, before the FFCodec.init() call. | ||
| 44 | */ | ||
| 45 | int ff_encode_preinit(struct AVCodecContext *avctx); | ||
| 46 | |||
| 47 | /** | ||
| 48 | * Perform decoder initialization and validation. | ||
| 49 | * Called when opening the decoder, before the FFCodec.init() call. | ||
| 50 | */ | ||
| 51 | int ff_decode_preinit(struct AVCodecContext *avctx); | ||
| 52 | |||
| 53 | #endif // AVCODEC_AVCODEC_INTERNAL_H | ||
| @@ -41,6 +41,7 @@ · 40 unmodified lines | |||
| 41 | #include "libavutil/opt.h" | 41 | #include "libavutil/opt.h" |
| 42 | 42 | ||
| 43 | #include "avcodec.h" | 43 | #include "avcodec.h" |
| 44 | #include "avcodec_internal.h" | ||
| 44 | #include "bytestream.h" | 45 | #include "bytestream.h" |
| 45 | #include "bsf.h" | 46 | #include "bsf.h" |
| 46 | #include "codec_internal.h" | 47 | #include "codec_internal.h" |
| @@ -53,11 +53,6 @@ typedef struct FrameDecodeData { · 52 unmodified lines | |||
| 53 | void (*hwaccel_priv_free)(void *priv); | 53 | void (*hwaccel_priv_free)(void *priv); |
| 54 | } FrameDecodeData; | 54 | } FrameDecodeData; |
| 55 | 55 | ||
| 56 | /** | ||
| 57 | * avcodec_receive_frame() implementation for decoders. | ||
| 58 | */ | ||
| 59 | int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame); | ||
| 60 | |||
| 61 | /** | 56 | /** |
| 62 | * Called by decoders to get the next packet for decoding. | 57 | * Called by decoders to get the next packet for decoding. |
| 63 | * | 58 | * |
| @@ -99,12 +94,6 @@ int ff_attach_decode_data(AVFrame *frame); · 35 unmodified lines | |||
| 99 | */ | 94 | */ |
| 100 | int ff_copy_palette(void *dst, const AVPacket *src, void *logctx); | 95 | int ff_copy_palette(void *dst, const AVPacket *src, void *logctx); |
| 101 | 96 | ||
| 102 | /** | ||
| 103 | * Perform decoder initialization and validation. | ||
| 104 | * Called when opening the decoder, before the FFCodec.init() call. | ||
| 105 | */ | ||
| 106 | int ff_decode_preinit(AVCodecContext *avctx); | ||
| 107 | |||
| 108 | /** | 97 | /** |
| 109 | * Check that the provided frame dimensions are valid and set them on the codec | 98 | * Check that the provided frame dimensions are valid and set them on the codec |
| 110 | * context. | 99 | * context. |
| @@ -27,6 +27,7 @@ · 26 unmodified lines | |||
| 27 | #include "libavutil/samplefmt.h" | 27 | #include "libavutil/samplefmt.h" |
| 28 | 28 | ||
| 29 | #include "avcodec.h" | 29 | #include "avcodec.h" |
| 30 | #include "avcodec_internal.h" | ||
| 30 | #include "codec_internal.h" | 31 | #include "codec_internal.h" |
| 31 | #include "encode.h" | 32 | #include "encode.h" |
| 32 | #include "frame_thread_encoder.h" | 33 | #include "frame_thread_encoder.h" |
| @@ -26,11 +26,6 @@ · 25 unmodified lines | |||
| 26 | #include "avcodec.h" | 26 | #include "avcodec.h" |
| 27 | #include "packet.h" | 27 | #include "packet.h" |
| 28 | 28 | ||
| 29 | /** | ||
| 30 | * avcodec_receive_frame() implementation for encoders. | ||
| 31 | */ | ||
| 32 | int ff_encode_receive_frame(AVCodecContext *avctx, AVFrame *frame); | ||
| 33 | |||
| 34 | /** | 29 | /** |
| 35 | * Called by encoders to get the next frame for encoding. | 30 | * Called by encoders to get the next frame for encoding. |
| 36 | * | 31 | * |
| @@ -75,12 +70,6 @@ int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size); · 38 unmodified lines | |||
| 75 | int ff_encode_reordered_opaque(AVCodecContext *avctx, | 70 | int ff_encode_reordered_opaque(AVCodecContext *avctx, |
| 76 | AVPacket *pkt, const AVFrame *frame); | 71 | AVPacket *pkt, const AVFrame *frame); |
| 77 | 72 | ||
| 78 | /* | ||
| 79 | * Perform encoder initialization and validation. | ||
| 80 | * Called when opening the encoder, before the FFCodec.init() call. | ||
| 81 | */ | ||
| 82 | int ff_encode_preinit(AVCodecContext *avctx); | ||
| 83 | |||
| 84 | int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, | 73 | int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, |
| 85 | AVFrame *frame, int *got_packet); | 74 | AVFrame *frame, int *got_packet); |
| 86 | 75 | ||