[FFmpeg-soc] [PATCH 6/9] Add the frame-threading support code.

Michael Niedermayer michaelni at gmx.at
Fri May 30 13:13:07 CEST 2008


On Wed, May 28, 2008 at 11:51:53PM -0400, Alexander Strange wrote:
> 
> ---
>   libavcodec/Makefile      |    2 +-
>   libavcodec/framethread.c |  342 +++++++++++++++++++++++++++++++++++++ 
> +++++++++
>   libavcodec/thread.c      |    7 +-
>   libavcodec/utils.c       |    7 +-
>   4 files changed, 353 insertions(+), 5 deletions(-)
>   create mode 100644 libavcodec/framethread.c
[...]
> +void ff_report_decode_progress(AVFrame *f, int n) {
> +    PerThreadContext *p;
> +    int *progress;
> +
> +    if (!f->avctx->thread_opaque) return;
> +
> +    p = f->avctx->thread_opaque;
> +    progress = f->thread_opaque;
> +
> +    pthread_mutex_lock(&p->progress_mutex);
> +    *progress = n;
> +    pthread_cond_broadcast(&p->progress_cond);
> +    pthread_mutex_unlock(&p->progress_mutex);
> +}
> +
> +void ff_await_decode_progress(AVFrame *f, int n) {
> +    PerThreadContext *p;
> +    int * volatile progress;
> +
> +    if (!f->avctx->thread_opaque) return;
> +
> +    p = f->avctx->thread_opaque;
> +    progress = f->thread_opaque;
> +
> +    if (*progress >= n) return;
> +
> +    pthread_mutex_lock(&p->progress_mutex);
> +    while (*progress < n)
> +        pthread_cond_wait(&p->progress_cond, &p->progress_mutex);
> +    pthread_mutex_unlock(&p->progress_mutex);
> +}

h264 can have up 1 motion vector per 4x4 pixels, thus if above is used
to check the availability of some blocks, it will need to be very fast
(millions of calls per second must take only a negligible amount of time)



[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct awnser.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20080530/207d4792/attachment.pgp>


More information about the FFmpeg-soc mailing list