extern void vp8_build_block_offsets(MACROBLOCK *x);
extern void vp8_setup_block_ptrs(MACROBLOCK *x);
-extern void loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm);
+extern void vp8_loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm);
-static THREAD_FUNCTION loopfilter_thread(void *p_data)
+static THREAD_FUNCTION thread_loopfilter(void *p_data)
{
VP8_COMP *cpi = (VP8_COMP *)(((LPFTHREAD_DATA *)p_data)->ptr1);
VP8_COMMON *cm = &cpi->common;
if (cpi->b_multi_threaded == 0) // we're shutting down
break;
- loopfilter_frame(cpi, cm);
+ vp8_loopfilter_frame(cpi, cm);
sem_post(&cpi->h_event_end_lpf);
}
cpi->b_multi_threaded = 0;
cpi->encoding_thread_count = 0;
+ cpi->b_lpf_running = 0;
if (cm->processor_core_count > 1 && cpi->oxcf.multi_threaded > 1)
{
sem_init(&cpi->h_event_end_lpf, 0, 0);
lpfthd->ptr1 = (void *)cpi;
- pthread_create(&cpi->h_filter_thread, 0, loopfilter_thread, lpfthd);
+ pthread_create(&cpi->h_filter_thread, 0, thread_loopfilter, lpfthd);
}
}
}
}
-void loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm)
+void vp8_loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm)
{
if (cm->no_lpf)
{
vp8_setup_key_frame(cpi);
}
+#if CONFIG_MULTITHREAD
+ /* wait for the last picture loopfilter thread done */
+ if (cpi->b_lpf_running)
+ {
+ sem_wait(&cpi->h_event_end_lpf);
+ cpi->b_lpf_running = 0;
+ }
+#endif
+
// transform / motion compensation build reconstruction frame
vp8_encode_frame(cpi);
if (cpi->b_multi_threaded)
{
sem_post(&cpi->h_event_start_lpf); /* start loopfilter in separate thread */
+ cpi->b_lpf_running = 1;
}
else
#endif
{
- loopfilter_frame(cpi, cm);
+ vp8_loopfilter_frame(cpi, cm);
}
update_reference_frames(cm);
vp8_pack_bitstream(cpi, dest, dest_end, size);
#if CONFIG_MULTITHREAD
- /* wait for loopfilter thread done */
- if (cpi->b_multi_threaded)
+ /* if PSNR packets are generated we have to wait for the lpf */
+ if (cpi->b_lpf_running && cpi->b_calculate_psnr)
{
sem_wait(&cpi->h_event_end_lpf);
+ cpi->b_lpf_running = 0;
}
#endif
else
{
int ret;
+
+#if CONFIG_MULTITHREAD
+ if(cpi->b_lpf_running)
+ {
+ sem_wait(&cpi->h_event_end_lpf);
+ cpi->b_lpf_running = 0;
+ }
+#endif
+
#if CONFIG_POSTPROC
ret = vp8_post_proc_frame(&cpi->common, dest, flags);
#else