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

wm4 nfxjfg at googlemail.com
Tue Mar 1 13:29:11 CET 2016


On Tue, 1 Mar 2016 11:31:18 +0100
Michael Niedermayer <michael at niedermayer.cc> wrote:

> 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

Indeed, it should be.


More information about the ffmpeg-devel mailing list