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>
This commit is contained in:
commit
2ec4586d77
@ -3307,6 +3307,29 @@ typedef struct AVHWAccel {
|
|||||||
* @param s the mpeg context
|
* @param s the mpeg context
|
||||||
*/
|
*/
|
||||||
void (*decode_mb)(struct MpegEncContext *s);
|
void (*decode_mb)(struct MpegEncContext *s);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the hwaccel private data.
|
||||||
|
*
|
||||||
|
* This will be called from ff_get_format(), after hwaccel and
|
||||||
|
* hwaccel_context are set and the hwaccel private data in AVCodecInternal
|
||||||
|
* is allocated.
|
||||||
|
*/
|
||||||
|
int (*init)(AVCodecContext *avctx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uninitialize the hwaccel private data.
|
||||||
|
*
|
||||||
|
* This will be called from get_format() or avcodec_close(), after hwaccel
|
||||||
|
* and hwaccel_context are already uninitialized.
|
||||||
|
*/
|
||||||
|
int (*uninit)(AVCodecContext *avctx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Size of the private data to allocate in
|
||||||
|
* AVCodecInternal.hwaccel_priv_data.
|
||||||
|
*/
|
||||||
|
int priv_data_size;
|
||||||
} AVHWAccel;
|
} AVHWAccel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,6 +122,11 @@ typedef struct AVCodecInternal {
|
|||||||
* Number of audio samples to skip at the start of the next decoded frame
|
* Number of audio samples to skip at the start of the next decoded frame
|
||||||
*/
|
*/
|
||||||
int skip_samples;
|
int skip_samples;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hwaccel-specific private data
|
||||||
|
*/
|
||||||
|
void *hwaccel_priv_data;
|
||||||
} AVCodecInternal;
|
} AVCodecInternal;
|
||||||
|
|
||||||
struct AVCodecDefault {
|
struct AVCodecDefault {
|
||||||
|
@ -226,6 +226,7 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
|
|||||||
dst->sample_rate = src->sample_rate;
|
dst->sample_rate = src->sample_rate;
|
||||||
dst->sample_fmt = src->sample_fmt;
|
dst->sample_fmt = src->sample_fmt;
|
||||||
dst->channel_layout = src->channel_layout;
|
dst->channel_layout = src->channel_layout;
|
||||||
|
dst->internal->hwaccel_priv_data = src->internal->hwaccel_priv_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (for_user) {
|
if (for_user) {
|
||||||
|
@ -1146,16 +1146,37 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
|
|||||||
if (!desc)
|
if (!desc)
|
||||||
return AV_PIX_FMT_NONE;
|
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) {
|
if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) {
|
||||||
avctx->hwaccel = find_hwaccel(avctx->codec_id, ret);
|
AVHWAccel *hwaccel;
|
||||||
if (!avctx->hwaccel) {
|
int err;
|
||||||
|
|
||||||
|
hwaccel = find_hwaccel(avctx->codec_id, ret);
|
||||||
|
if (!hwaccel) {
|
||||||
av_log(avctx, AV_LOG_ERROR,
|
av_log(avctx, AV_LOG_ERROR,
|
||||||
"Could not find an AVHWAccel for the pixel format: %s",
|
"Could not find an AVHWAccel for the pixel format: %s",
|
||||||
desc->name);
|
desc->name);
|
||||||
return AV_PIX_FMT_NONE;
|
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;
|
return ret;
|
||||||
@ -2689,6 +2710,11 @@ av_cold int avcodec_close(AVCodecContext *avctx)
|
|||||||
for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++)
|
for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++)
|
||||||
av_buffer_pool_uninit(&pool->pools[i]);
|
av_buffer_pool_uninit(&pool->pools[i]);
|
||||||
av_freep(&avctx->internal->pool);
|
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);
|
av_freep(&avctx->internal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user