c->parent_avctx->release_buffer(c->parent_avctx, frame);
pthread_mutex_unlock(&c->buffer_mutex);
av_freep(&frame);
- if(!got_packet)
- continue;
- av_dup_packet(pkt);
+ if(got_packet) {
+ av_dup_packet(pkt);
+ } else {
+ pkt->data = NULL;
+ pkt->size = 0;
+ }
pthread_mutex_lock(&c->finished_task_mutex);
c->finished_tasks[task.index].outdata = pkt; pkt = NULL;
c->finished_tasks[task.index].return_code = ret;
for(i=0; i<avctx->thread_count ; i++){
AVDictionary *tmp = NULL;
+ void *tmpv;
AVCodecContext *thread_avctx = avcodec_alloc_context3(avctx->codec);
if(!thread_avctx)
goto fail;
+ tmpv = thread_avctx->priv_data;
*thread_avctx = *avctx;
+ thread_avctx->priv_data = tmpv;
thread_avctx->internal = NULL;
- thread_avctx->priv_data = av_malloc(avctx->codec->priv_data_size);
- if(!thread_avctx->priv_data) {
- av_freep(&thread_avctx);
- goto fail;
- }
memcpy(thread_avctx->priv_data, avctx->priv_data, avctx->codec->priv_data_size);
thread_avctx->thread_count = 1;
thread_avctx->active_thread_type &= ~FF_THREAD_FRAME;
}
task = c->finished_tasks[c->finished_task_index];
*pkt = *(AVPacket*)(task.outdata);
- c->finished_tasks[c->finished_task_index].outdata= NULL;
+ if(pkt->data)
+ *got_packet_ptr = 1;
+ av_freep(&c->finished_tasks[c->finished_task_index].outdata);
c->finished_task_index = (c->finished_task_index+1) % BUFFER_SIZE;
pthread_mutex_unlock(&c->finished_task_mutex);
- *got_packet_ptr = 1;
-
return task.return_code;
}