[FFmpeg-devel] [PATCH v9] VideoToolbox H.264 Encoder

Michael Niedermayer michael at niedermayer.cc
Tue Mar 1 11:31:18 CET 2016


On Tue, Mar 01, 2016 at 01:40:53PM +0800, Rick Kern wrote:
> Autodetected by default. Encode using -codec:v vtenc.
[...]
> +static void set_async_error(VTEncContext *vtctx, int err)
> +{
> +    BufNode *info;
> +
> +    pthread_mutex_lock(&vtctx->lock);
> +
> +    vtctx->async_error = err;
> +
> +    info = vtctx->q_head;
> +    vtctx->q_head = vtctx->q_tail = NULL;
> +
> +    while (info) {
> +        BufNode *next = info->next;
> +        CFRelease(info->cm_buffer);
> +        free(info);

should probably av_free()

> +        info = next;
> +    }
> +
> +    pthread_mutex_unlock(&vtctx->lock);
> +}
> +
> +static int vtenc_q_pop(VTEncContext *vtctx, bool wait, CMSampleBufferRef *buf)
> +{
> +    BufNode *info;
> +
> +    pthread_mutex_lock(&vtctx->lock);
> +
> +    if (vtctx->async_error) {
> +        pthread_mutex_unlock(&vtctx->lock);
> +        return vtctx->async_error;
> +    }
> +
> +    if (vtctx->flushing && vtctx->frame_ct_in == vtctx->frame_ct_out) {
> +        *buf = NULL;
> +
> +        pthread_mutex_unlock(&vtctx->lock);
> +        return 0;
> +    }
> +
> +    while (!vtctx->q_head && !vtctx->async_error && wait) {
> +        pthread_cond_wait(&vtctx->cv_sample_sent, &vtctx->lock);
> +    }
> +
> +    if (!vtctx->q_head) {
> +        pthread_mutex_unlock(&vtctx->lock);
> +        *buf = NULL;
> +        return 0;
> +    }
> +
> +    info = vtctx->q_head;
> +    vtctx->q_head = vtctx->q_head->next;
> +    if (!vtctx->q_head) {
> +        vtctx->q_tail = NULL;
> +    }
> +
> +    pthread_mutex_unlock(&vtctx->lock);
> +
> +    *buf = info->cm_buffer;

> +    free(info);

same

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

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160301/71f57a84/attachment.sig>


More information about the ffmpeg-devel mailing list