#include <CoreFoundation/CFData.h>
#include <CoreFoundation/CFString.h>
-#include "avcodec.h"
+#include "libavutil/avutil.h"
#include "vda_internal.h"
-/**
- * \addtogroup VDA_Decoding
- *
- * @{
- */
-
-/* Mutex manager callback. */
-static int vda_lock_operation(void **mtx, enum AVLockOp op)
-{
- switch (op) {
- case AV_LOCK_CREATE:
- *mtx = av_malloc(sizeof(pthread_mutex_t));
- if (!*mtx)
- return 1;
- return !!pthread_mutex_init(*mtx, NULL);
- case AV_LOCK_OBTAIN:
- return !!pthread_mutex_lock(*mtx);
- case AV_LOCK_RELEASE:
- return !!pthread_mutex_unlock(*mtx);
- case AV_LOCK_DESTROY:
- pthread_mutex_destroy(*mtx);
- av_freep(mtx);
- return 0;
- }
- return 1;
-}
-
/* Helper to create a dictionary according to the given pts. */
static CFDictionaryRef vda_dictionary_with_pts(int64_t i_pts)
{
{
vda_frame *top_frame;
- vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_OBTAIN);
+ pthread_mutex_lock(&vda_ctx->queue_mutex);
while (vda_ctx->queue) {
top_frame = vda_ctx->queue;
ff_vda_release_vda_frame(top_frame);
}
- vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_RELEASE);
+ pthread_mutex_unlock(&vda_ctx->queue_mutex);
}
new_frame->cv_buffer = CVPixelBufferRetain(image_buffer);
new_frame->pts = vda_pts_from_dictionary(user_info);
- vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_OBTAIN);
+ pthread_mutex_lock(&vda_ctx->queue_mutex);
queue_walker = vda_ctx->queue;
}
}
- vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_RELEASE);
+ pthread_mutex_unlock(&vda_ctx->queue_mutex);
}
int ff_vda_create_decoder(struct vda_context *vda_ctx,
vda_ctx->bitstream = NULL;
vda_ctx->ref_size = 0;
- if (av_lockmgr_register(vda_lock_operation))
- return -1;
+ pthread_mutex_init(&vda_ctx->queue_mutex, NULL);
- vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_CREATE);
+ if (extradata[4]==0xFE) {
+ // convert 3 byte NAL sizes to 4 byte
+ extradata[4] = 0xFF;
+ }
config_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
4,
vda_clear_queue(vda_ctx);
- if (vda_ctx->queue_mutex)
- vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_DESTROY);
+ pthread_mutex_destroy(&vda_ctx->queue_mutex);
if (vda_ctx->bitstream)
av_freep(&vda_ctx->bitstream);
if (!vda_ctx->queue)
return NULL;
- vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_OBTAIN);
+ pthread_mutex_lock(&vda_ctx->queue_mutex);
top_frame = vda_ctx->queue;
vda_ctx->queue = top_frame->next_frame;
- vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_RELEASE);
+ pthread_mutex_unlock(&vda_ctx->queue_mutex);
return top_frame;
}
return 0;
}
-
-/* @} */