API changes, most recent first:
+2012-01-31 - xxxxxxx - lavc 54.01.0
+ Add avcodec_is_open() function.
+
2012-01-30 - xxxxxxx - lavu 51.22.0 - intfloat.h
Add a new installed header libavutil/intfloat.h with int/float punning
functions.
*/
const AVClass *avcodec_get_class(void);
+/**
+ * @return a positive value if s is open (i.e. avcodec_open2() was called on it
+ * with no corresponding avcodec_close()), 0 otherwise.
+ */
+int avcodec_is_open(AVCodecContext *s);
+
#endif /* AVCODEC_AVCODEC_H */
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
{
- if (dest->codec) { // check that the dest context is uninitialized
+ if (avcodec_is_open(dest)) { // check that the dest context is uninitialized
av_log(dest, AV_LOG_ERROR,
"Tried to copy AVCodecContext %p into already-initialized %p\n",
src, dest);
int ret = 0;
AVDictionary *tmp = NULL;
+ if (avcodec_is_open(avctx))
+ return 0;
+
if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
return AVERROR(EINVAL);
return AVMEDIA_TYPE_UNKNOWN;
}
+
+int avcodec_is_open(AVCodecContext *s)
+{
+ return !!s->internal;
+}
AVFrame picture;
AVPacket pkt = *avpkt;
- if(!st->codec->codec){
+ if (!avcodec_is_open(st->codec)) {
AVDictionary *thread_opt = NULL;
codec = avcodec_find_decoder(st->codec->codec_id);
// close codecs which were opened in try_decode_frame()
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
- if(st->codec->codec)
- avcodec_close(st->codec);
+ avcodec_close(st->codec);
}
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];