[FFmpeg-devel] custom execute2 access violation?
Robert Nagy
ronag89 at gmail.com
Fri Dec 2 23:59:40 CET 2011
Could anyone explain why the following code gets an access violation while
trying to encode DNXHD.
int thread_execute(AVCodecContext* s, int (*func)(AVCodecContext *c2, void
*arg2), void* arg, int* ret, int count, int size)
{
tbb::parallel_for(0, count, 1, [&](int i)
{
int r = func(s, (char*)arg + i*size);
if(ret)
ret[i] = r;
});
return 0;
}
int thread_execute2(AVCodecContext* s, int (*func)(AVCodecContext* c2,
void* arg2, int, int), void* arg, int* ret, int count)
{
for(int i = 0; i < count; i++)
{
int r = func(s, arg, i, 0); // access violation on i == 0. <--
ACCESS VIOLATION HERE
if(ret)
ret[i] = r;
}
return 0;
}
int tbb_avcodec_open(AVCodecContext* avctx, AVCodec* codec)
{
int ret = avcodec_open(avctx, codec);
avctx->execute = thread_execute;
avctx->execute2 = thread_execute2;
return ret;
}
int tbb_avcodec_close(AVCodecContext* avctx)
{
return avcodec_close(avctx);
}
//void thread_init(AVCodecContext* s)
//{
// static const size_t MAX_THREADS = 16; // See mpegvideo.h
// static int dummy_opaque;
//
// s->active_thread_type = FF_THREAD_SLICE;
// s->thread_opaque = &dummy_opaque;
// s->execute = thread_execute;
// s->execute2 = thread_execute2;
// s->thread_count = MAX_THREADS; // We are using a task-scheduler, so
use as many "threads/tasks" as possible.
//}
//
//void thread_free(AVCodecContext* s)
//{
// if(!s->thread_opaque)
// return;
//
// s->thread_opaque = nullptr;
//}
//
//int tbb_avcodec_open(AVCodecContext* avctx, AVCodec* codec)
//{
// //CodecID supported_codecs[] = {CODEC_ID_MPEG2VIDEO, CODEC_ID_PRORES,
CODEC_ID_FFV1, CODEC_ID_DNXHD, CODEC_ID_DVVIDEO};
//
// avctx->thread_count = 1;
// if((codec->capabilities & CODEC_CAP_SLICE_THREADS) &&
// (avctx->thread_type & FF_THREAD_SLICE))
// {
// thread_init(avctx);
// }
// // ff_thread_init will not be executed since thread_opaque != nullptr ||
thread_count == 1.
// return avcodec_open(avctx, codec);
//}
//
//int tbb_avcodec_close(AVCodecContext* avctx)
//{
// thread_free(avctx);
// // ff_thread_free will not be executed since thread_opaque == nullptr.
// return avcodec_close(avctx);
//}
More information about the ffmpeg-devel
mailing list