Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-05-12 02:21:44 +0400
committerMichael Niedermayer <michaelni@gmx.at>2014-05-12 02:21:44 +0400
commit2ec4586d77c18eff38c128936a67b7d7a2e7f9a0 (patch)
tree376a5dc29dc6421c52dc395aef14ee6429f1eb68 /libavcodec/utils.c
parentc4fe50b954a0490c54efca19682cfae00eba3145 (diff)
parentdd2d3b766b20196d0b65a82e3d897ccecbf7adb8 (diff)
Merge commit 'dd2d3b766b20196d0b65a82e3d897ccecbf7adb8'
* commit 'dd2d3b766b20196d0b65a82e3d897ccecbf7adb8': lavc: Add hwaccel private data and init/uninit callbacks Conflicts: libavcodec/avcodec.h libavcodec/internal.h libavcodec/pthread_frame.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 925c26ed83..a06ded30c8 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1146,16 +1146,37 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
if (!desc)
return AV_PIX_FMT_NONE;
+ if (avctx->hwaccel && avctx->hwaccel->uninit)
+ avctx->hwaccel->uninit(avctx);
+ av_freep(&avctx->internal->hwaccel_priv_data);
+ avctx->hwaccel = NULL;
+
if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
- avctx->hwaccel = find_hwaccel(avctx->codec_id, ret);
- if (!avctx->hwaccel) {
+ AVHWAccel *hwaccel;
+ int err;
+
+ hwaccel = find_hwaccel(avctx->codec_id, ret);
+ if (!hwaccel) {
av_log(avctx, AV_LOG_ERROR,
"Could not find an AVHWAccel for the pixel format: %s",
desc->name);
return AV_PIX_FMT_NONE;
}
- } else {
- avctx->hwaccel = NULL;
+
+ if (hwaccel->priv_data_size) {
+ avctx->internal->hwaccel_priv_data = av_mallocz(hwaccel->priv_data_size);
+ if (!avctx->internal->hwaccel_priv_data)
+ return AV_PIX_FMT_NONE;
+ }
+
+ if (hwaccel->init) {
+ err = hwaccel->init(avctx);
+ if (err < 0) {
+ av_freep(&avctx->internal->hwaccel_priv_data);
+ return AV_PIX_FMT_NONE;
+ }
+ }
+ avctx->hwaccel = hwaccel;
}
return ret;
@@ -2689,6 +2710,11 @@ av_cold int avcodec_close(AVCodecContext *avctx)
for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++)
av_buffer_pool_uninit(&pool->pools[i]);
av_freep(&avctx->internal->pool);
+
+ if (avctx->hwaccel && avctx->hwaccel->uninit)
+ avctx->hwaccel->uninit(avctx);
+ av_freep(&avctx->internal->hwaccel_priv_data);
+
av_freep(&avctx->internal);
}