Mercurial > libavcodec.hg
comparison avcodec.h @ 9355:54bc8a2727b0 libavcodec
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
AVPacket argument rather than a const uint8_t *buf + int buf_size. This allows
passing of packet-specific flags from demuxer to decoder, such as the keyframe
flag, which appears necessary to playback corePNG P-frames.
Patch by Thilo Borgmann thilo.borgmann googlemail com, see also the thread
"Google Summer of Code participation" on the mailinglist.
| author | rbultje |
|---|---|
| date | Tue, 07 Apr 2009 15:59:50 +0000 |
| parents | 174309386512 |
| children | 2108342734cc |
comparison
equal
deleted
inserted
replaced
| 9354:174309386512 | 9355:54bc8a2727b0 |
|---|---|
| 2427 enum CodecID id; | 2427 enum CodecID id; |
| 2428 int priv_data_size; | 2428 int priv_data_size; |
| 2429 int (*init)(AVCodecContext *); | 2429 int (*init)(AVCodecContext *); |
| 2430 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data); | 2430 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data); |
| 2431 int (*close)(AVCodecContext *); | 2431 int (*close)(AVCodecContext *); |
| 2432 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, | 2432 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt); |
| 2433 const uint8_t *buf, int buf_size); | |
| 2434 /** | 2433 /** |
| 2435 * Codec capabilities. | 2434 * Codec capabilities. |
| 2436 * see CODEC_CAP_* | 2435 * see CODEC_CAP_* |
| 2437 */ | 2436 */ |
| 2438 int capabilities; | 2437 int capabilities; |
| 3018 * @return zero on success, a negative value on error | 3017 * @return zero on success, a negative value on error |
| 3019 * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder | 3018 * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder |
| 3020 */ | 3019 */ |
| 3021 int avcodec_open(AVCodecContext *avctx, AVCodec *codec); | 3020 int avcodec_open(AVCodecContext *avctx, AVCodec *codec); |
| 3022 | 3021 |
| 3022 #if LIBAVCODEC_VERSION_MAJOR < 53 | |
| 3023 /** | 3023 /** |
| 3024 * Decodes an audio frame from \p buf into \p samples. | 3024 * Decodes an audio frame from \p buf into \p samples. |
| 3025 * The avcodec_decode_audio2() function decodes an audio frame from the input | 3025 * Wrapper function which calls avcodec_decode_audio3. |
| 3026 * buffer \p buf of size \p buf_size. To decode it, it makes use of the | 3026 * |
| 3027 * @deprecated Use avcodec_decode_audio3 instead. | |
| 3028 * @param avctx the codec context | |
| 3029 * @param[out] samples the output buffer | |
| 3030 * @param[in,out] frame_size_ptr the output buffer size in bytes | |
| 3031 * @param[in] buf the input buffer | |
| 3032 * @param[in] buf_size the input buffer size in bytes | |
| 3033 * @return On error a negative value is returned, otherwise the number of bytes | |
| 3034 * used or zero if no frame could be decompressed. | |
| 3035 */ | |
| 3036 attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, | |
| 3037 int *frame_size_ptr, | |
| 3038 const uint8_t *buf, int buf_size); | |
| 3039 #endif | |
| 3040 | |
| 3041 /** | |
| 3042 * Decodes an audio frame from \p avpkt->data into \p samples. | |
| 3043 * The avcodec_decode_audio3() function decodes an audio frame from the input | |
| 3044 * buffer \p avpkt->data of size \p avpkt->size. To decode it, it makes use of the | |
| 3027 * audio codec which was coupled with \p avctx using avcodec_open(). The | 3045 * audio codec which was coupled with \p avctx using avcodec_open(). The |
| 3028 * resulting decoded frame is stored in output buffer \p samples. If no frame | 3046 * resulting decoded frame is stored in output buffer \p samples. If no frame |
| 3029 * could be decompressed, \p frame_size_ptr is zero. Otherwise, it is the | 3047 * could be decompressed, \p frame_size_ptr is zero. Otherwise, it is the |
| 3030 * decompressed frame size in \e bytes. | 3048 * decompressed frame size in \e bytes. |
| 3031 * | 3049 * |
| 3032 * @warning You \e must set \p frame_size_ptr to the allocated size of the | 3050 * @warning You \e must set \p frame_size_ptr to the allocated size of the |
| 3033 * output buffer before calling avcodec_decode_audio2(). | 3051 * output buffer before calling avcodec_decode_audio3(). |
| 3034 * | 3052 * |
| 3035 * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than | 3053 * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than |
| 3036 * the actual read bytes because some optimized bitstream readers read 32 or 64 | 3054 * the actual read bytes because some optimized bitstream readers read 32 or 64 |
| 3037 * bits at once and could read over the end. | 3055 * bits at once and could read over the end. |
| 3038 * | 3056 * |
| 3039 * @warning The end of the input buffer \p buf should be set to 0 to ensure that | 3057 * @warning The end of the input buffer \p avpkt->data should be set to 0 to ensure that |
| 3040 * no overreading happens for damaged MPEG streams. | 3058 * no overreading happens for damaged MPEG streams. |
| 3041 * | 3059 * |
| 3042 * @note You might have to align the input buffer \p buf and output buffer \p | 3060 * @note You might have to align the input buffer \p avpkt->data and output buffer \p |
| 3043 * samples. The alignment requirements depend on the CPU: On some CPUs it isn't | 3061 * samples. The alignment requirements depend on the CPU: On some CPUs it isn't |
| 3044 * necessary at all, on others it won't work at all if not aligned and on others | 3062 * necessary at all, on others it won't work at all if not aligned and on others |
| 3045 * it will work but it will have an impact on performance. In practice, the | 3063 * it will work but it will have an impact on performance. In practice, the |
| 3046 * bitstream should have 4 byte alignment at minimum and all sample data should | 3064 * bitstream should have 4 byte alignment at minimum and all sample data should |
| 3047 * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If | 3065 * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If |
| 3049 * start of the buffer to 16. | 3067 * start of the buffer to 16. |
| 3050 * | 3068 * |
| 3051 * @param avctx the codec context | 3069 * @param avctx the codec context |
| 3052 * @param[out] samples the output buffer | 3070 * @param[out] samples the output buffer |
| 3053 * @param[in,out] frame_size_ptr the output buffer size in bytes | 3071 * @param[in,out] frame_size_ptr the output buffer size in bytes |
| 3054 * @param[in] buf the input buffer | 3072 * @param[in] avpkt The input AVPacket containing the input buffer. |
| 3055 * @param[in] buf_size the input buffer size in bytes | |
| 3056 * @return On error a negative value is returned, otherwise the number of bytes | 3073 * @return On error a negative value is returned, otherwise the number of bytes |
| 3057 * used or zero if no frame could be decompressed. | 3074 * used or zero if no frame could be decompressed. |
| 3058 */ | 3075 */ |
| 3059 int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, | 3076 int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, |
| 3060 int *frame_size_ptr, | 3077 int *frame_size_ptr, |
| 3078 AVPacket *avpkt); | |
| 3079 | |
| 3080 #if LIBAVCODEC_VERSION_MAJOR < 53 | |
| 3081 /** | |
| 3082 * Decodes a video frame from \p buf into \p picture. | |
| 3083 * Wrapper function which calls avcodec_decode_video2. | |
| 3084 * | |
| 3085 * @deprecated Use avcodec_decode_video2 instead. | |
| 3086 * @param avctx the codec context | |
| 3087 * @param[out] picture The AVFrame in which the decoded video frame will be stored. | |
| 3088 * @param[in] buf the input buffer | |
| 3089 * @param[in] buf_size the size of the input buffer in bytes | |
| 3090 * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. | |
| 3091 * @return On error a negative value is returned, otherwise the number of bytes | |
| 3092 * used or zero if no frame could be decompressed. | |
| 3093 */ | |
| 3094 attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, | |
| 3095 int *got_picture_ptr, | |
| 3061 const uint8_t *buf, int buf_size); | 3096 const uint8_t *buf, int buf_size); |
| 3062 | 3097 #endif |
| 3063 /** | 3098 |
| 3064 * Decodes a video frame from \p buf into \p picture. | 3099 /** |
| 3065 * The avcodec_decode_video() function decodes a video frame from the input | 3100 * Decodes a video frame from \p avpkt->data into \p picture. |
| 3066 * buffer \p buf of size \p buf_size. To decode it, it makes use of the | 3101 * The avcodec_decode_video2() function decodes a video frame from the input |
| 3102 * buffer \p avpkt->data of size \p avpkt->size. To decode it, it makes use of the | |
| 3067 * video codec which was coupled with \p avctx using avcodec_open(). The | 3103 * video codec which was coupled with \p avctx using avcodec_open(). The |
| 3068 * resulting decoded frame is stored in \p picture. | 3104 * resulting decoded frame is stored in \p picture. |
| 3069 * | 3105 * |
| 3070 * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than | 3106 * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than |
| 3071 * the actual read bytes because some optimized bitstream readers read 32 or 64 | 3107 * the actual read bytes because some optimized bitstream readers read 32 or 64 |
| 3072 * bits at once and could read over the end. | 3108 * bits at once and could read over the end. |
| 3073 * | 3109 * |
| 3074 * @warning The end of the input buffer \p buf should be set to 0 to ensure that | 3110 * @warning The end of the input buffer \p buf should be set to 0 to ensure that |
| 3075 * no overreading happens for damaged MPEG streams. | 3111 * no overreading happens for damaged MPEG streams. |
| 3076 * | 3112 * |
| 3077 * @note You might have to align the input buffer \p buf and output buffer \p | 3113 * @note You might have to align the input buffer \p avpkt->data and output buffer \p |
| 3078 * samples. The alignment requirements depend on the CPU: on some CPUs it isn't | 3114 * samples. The alignment requirements depend on the CPU: on some CPUs it isn't |
| 3079 * necessary at all, on others it won't work at all if not aligned and on others | 3115 * necessary at all, on others it won't work at all if not aligned and on others |
| 3080 * it will work but it will have an impact on performance. In practice, the | 3116 * it will work but it will have an impact on performance. In practice, the |
| 3081 * bitstream should have 4 byte alignment at minimum and all sample data should | 3117 * bitstream should have 4 byte alignment at minimum and all sample data should |
| 3082 * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If | 3118 * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If |
| 3083 * the linesize is not a multiple of 16 then there's no sense in aligning the | 3119 * the linesize is not a multiple of 16 then there's no sense in aligning the |
| 3084 * start of the buffer to 16. | 3120 * start of the buffer to 16. |
| 3085 * | 3121 * |
| 3086 * @note Some codecs have a delay between input and output, these need to be | 3122 * @note Some codecs have a delay between input and output, these need to be |
| 3087 * feeded with buf=NULL, buf_size=0 at the end to return the remaining frames. | 3123 * feeded with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames. |
| 3088 * | 3124 * |
| 3089 * @param avctx the codec context | 3125 * @param avctx the codec context |
| 3090 * @param[out] picture The AVFrame in which the decoded video frame will be stored. | 3126 * @param[out] picture The AVFrame in which the decoded video frame will be stored. |
| 3091 * @param[in] buf the input buffer | 3127 * @param[in] avpkt The input AVpacket containing the input buffer. |
| 3092 * @param[in] buf_size the size of the input buffer in bytes | |
| 3093 * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. | 3128 * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. |
| 3094 * @return On error a negative value is returned, otherwise the number of bytes | 3129 * @return On error a negative value is returned, otherwise the number of bytes |
| 3095 * used or zero if no frame could be decompressed. | 3130 * used or zero if no frame could be decompressed. |
| 3096 */ | 3131 */ |
| 3097 int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, | 3132 int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, |
| 3098 int *got_picture_ptr, | 3133 int *got_picture_ptr, |
| 3099 const uint8_t *buf, int buf_size); | 3134 AVPacket *avpkt); |
| 3100 | 3135 |
| 3136 #if LIBAVCODEC_VERSION_MAJOR < 53 | |
| 3101 /* Decode a subtitle message. Return -1 if error, otherwise return the | 3137 /* Decode a subtitle message. Return -1 if error, otherwise return the |
| 3102 * number of bytes used. If no subtitle could be decompressed, | 3138 * number of bytes used. If no subtitle could be decompressed, |
| 3103 * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */ | 3139 * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */ |
| 3104 int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, | 3140 attribute_deprecated int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, |
| 3105 int *got_sub_ptr, | 3141 int *got_sub_ptr, |
| 3106 const uint8_t *buf, int buf_size); | 3142 const uint8_t *buf, int buf_size); |
| 3143 #endif | |
| 3144 | |
| 3145 /** | |
| 3146 * Decodes a subtitle message. | |
| 3147 * Returns -1 if error, otherwise returns the number of bytes used. | |
| 3148 * If no subtitle could be decompressed, \p got_sub_ptr is zero. | |
| 3149 * Otherwise, the subtitle is stored in \p *sub. | |
| 3150 * | |
| 3151 * @param avctx the codec context | |
| 3152 * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored. | |
| 3153 * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero. | |
| 3154 * @param[in] avpkt The input AVPacket containing the input buffer. | |
| 3155 */ | |
| 3156 int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, | |
| 3157 int *got_sub_ptr, | |
| 3158 AVPacket *avpkt); | |
| 3107 int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, | 3159 int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, |
| 3108 int *data_size_ptr, | 3160 int *data_size_ptr, |
| 3109 uint8_t *buf, int buf_size); | 3161 uint8_t *buf, int buf_size); |
| 3110 | 3162 |
| 3111 /** | 3163 /** |
