Merge remote-tracking branch 'qatar/release/0.8' into release/0.10
* qatar/release/0.8: (154 commits) Update Changelog for the 0.8.1 Release dca: include libavutil/mathematics.h for possibly missing M_SQRT1_2 dca: don't use av_clip_uintp2(). snow: check reference frame indices. snow: reject unsupported chroma shifts. xa_adpcm: limit filter to prevent xa_adpcm_table[] array bounds overruns. h264: increase reference poc list from 16 to 32. h264: stricter reference limit enforcement. h264: improve parsing of broken AVC SPS Replace computations of remaining bits with calls to get_bits_left(). png: convert to bytestream2 API. roqvideo: convert to bytestream2 API. smc: port to bytestream2 API. tgq: convert to bytestream2 API. algmm: convert to bytestream2 API. jvdec: unbreak video decoding h264: Fix invalid interlaced/progressive MB combinations for direct mode prediction. libx264: add 'stats' private option for setting 2pass stats filename. libx264: fix help text for slice-max-size option. avconv: reindent ... Conflicts: Changelog RELEASE avconv.c doc/APIchanges ffplay.c libavcodec/Makefile libavcodec/aacdec.c libavcodec/alsdec.c libavcodec/atrac3.c libavcodec/avcodec.h libavcodec/dvdata.c libavcodec/fraps.c libavcodec/golomb.h libavcodec/h264.c libavcodec/h264.h libavcodec/h264_cabac.c libavcodec/h264_cavlc.c libavcodec/h264_direct.c libavcodec/h264_parser.c libavcodec/h264_ps.c libavcodec/h264idct_template.c libavcodec/indeo3.c libavcodec/kgv1dec.c libavcodec/kmvc.c libavcodec/mjpegbdec.c libavcodec/mmvideo.c libavcodec/mpegaudiodec.c libavcodec/mpegvideo.h libavcodec/options.c libavcodec/pngdec.c libavcodec/roqvideodec.c libavcodec/shorten.c libavcodec/svq3.c libavcodec/utils.c libavcodec/version.h libavcodec/wmadec.c libavcodec/xxan.c libavformat/Makefile libavformat/asfdec.c libavformat/dv.c libavformat/mov.c libavformat/nsvdec.c libavformat/utils.c libavformat/version.h libavutil/avutil.h libavutil/error.c libavutil/error.h libswscale/swscale.c libswscale/utils.c libswscale/x86/swscale_template.c tests/ref/acodec/g722 Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -703,6 +703,21 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD
|
||||
int ret = 0;
|
||||
AVDictionary *tmp = NULL;
|
||||
|
||||
if (avcodec_is_open(avctx))
|
||||
return 0;
|
||||
|
||||
if ((!codec && !avctx->codec)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "No codec provided to avcodec_open2().\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if ((codec && avctx->codec && codec != avctx->codec)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, "
|
||||
"but %s passed to avcodec_open2().\n", avctx->codec->name, codec->name);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (!codec)
|
||||
codec = avctx->codec;
|
||||
|
||||
if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
@@ -722,11 +737,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD
|
||||
goto end;
|
||||
}
|
||||
|
||||
if(avctx->codec || !codec) {
|
||||
ret = AVERROR(EINVAL);
|
||||
goto end;
|
||||
}
|
||||
|
||||
avctx->internal = av_mallocz(sizeof(AVCodecInternal));
|
||||
if (!avctx->internal) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
@@ -816,6 +826,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD
|
||||
avctx->error_recognition, avctx->err_recognition);
|
||||
#endif
|
||||
|
||||
if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
|
||||
(!avctx->time_base.num || !avctx->time_base.den)) {
|
||||
avctx->time_base.num = 1;
|
||||
avctx->time_base.den = avctx->sample_rate;
|
||||
}
|
||||
|
||||
if (!HAVE_THREADS)
|
||||
av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n");
|
||||
|
||||
@@ -1421,14 +1437,17 @@ av_cold int avcodec_close(AVCodecContext *avctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (HAVE_THREADS && avctx->thread_opaque)
|
||||
ff_thread_free(avctx);
|
||||
if (avctx->codec && avctx->codec->close)
|
||||
avctx->codec->close(avctx);
|
||||
avcodec_default_free_buffers(avctx);
|
||||
avctx->coded_frame = NULL;
|
||||
av_freep(&avctx->internal);
|
||||
if (avctx->codec && avctx->codec->priv_class)
|
||||
if (avcodec_is_open(avctx)) {
|
||||
if (HAVE_THREADS && avctx->thread_opaque)
|
||||
ff_thread_free(avctx);
|
||||
if (avctx->codec && avctx->codec->close)
|
||||
avctx->codec->close(avctx);
|
||||
avcodec_default_free_buffers(avctx);
|
||||
avctx->coded_frame = NULL;
|
||||
av_freep(&avctx->internal);
|
||||
}
|
||||
|
||||
if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
|
||||
av_opt_free(avctx->priv_data);
|
||||
av_opt_free(avctx);
|
||||
av_freep(&avctx->priv_data);
|
||||
@@ -2009,3 +2028,8 @@ enum AVMediaType avcodec_get_type(enum CodecID codec_id)
|
||||
|
||||
return AVMEDIA_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
int avcodec_is_open(AVCodecContext *s)
|
||||
{
|
||||
return !!s->internal;
|
||||
}
|
||||
|
Reference in New Issue
Block a user