1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

vda: use K&R style.

This commit is contained in:
Clément Bœsch 2011-11-15 00:17:31 +01:00 committed by Sebastien Zwickert
parent 2b1a4c5b34
commit edc26bfae5
2 changed files with 32 additions and 42 deletions

View File

@ -38,21 +38,20 @@
/* Mutex manager callback. */ /* Mutex manager callback. */
static int vda_lock_operation(void **mtx, enum AVLockOp op) static int vda_lock_operation(void **mtx, enum AVLockOp op)
{ {
switch(op) switch (op) {
{ case AV_LOCK_CREATE:
case AV_LOCK_CREATE: *mtx = av_malloc(sizeof(pthread_mutex_t));
*mtx = av_malloc(sizeof(pthread_mutex_t)); if (!*mtx)
if(!*mtx) return 1;
return 1; return !!pthread_mutex_init(*mtx, NULL);
return !!pthread_mutex_init(*mtx, NULL); case AV_LOCK_OBTAIN:
case AV_LOCK_OBTAIN: return !!pthread_mutex_lock(*mtx);
return !!pthread_mutex_lock(*mtx); case AV_LOCK_RELEASE:
case AV_LOCK_RELEASE: return !!pthread_mutex_unlock(*mtx);
return !!pthread_mutex_unlock(*mtx); case AV_LOCK_DESTROY:
case AV_LOCK_DESTROY: pthread_mutex_destroy(*mtx);
pthread_mutex_destroy(*mtx); av_freep(mtx);
av_freep(mtx); return 0;
return 0;
} }
return 1; return 1;
} }
@ -62,12 +61,12 @@ static CFDictionaryRef vda_dictionary_with_pts(int64_t i_pts)
{ {
CFStringRef key = CFSTR("FF_VDA_DECODER_PTS_KEY"); CFStringRef key = CFSTR("FF_VDA_DECODER_PTS_KEY");
CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &i_pts); CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &i_pts);
CFDictionaryRef user_info = CFDictionaryCreate( kCFAllocatorDefault, CFDictionaryRef user_info = CFDictionaryCreate(kCFAllocatorDefault,
(const void **)&key, (const void **)&key,
(const void **)&value, (const void **)&value,
1, 1,
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks); &kCFTypeDictionaryValueCallBacks);
CFRelease(value); CFRelease(value);
return user_info; return user_info;
} }
@ -96,8 +95,7 @@ static void vda_clear_queue(struct vda_context *vda_ctx)
vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_OBTAIN); vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_OBTAIN);
while (vda_ctx->queue) while (vda_ctx->queue) {
{
top_frame = vda_ctx->queue; top_frame = vda_ctx->queue;
vda_ctx->queue = top_frame->next_frame; vda_ctx->queue = top_frame->next_frame;
ff_vda_release_vda_frame(top_frame); ff_vda_release_vda_frame(top_frame);
@ -136,23 +134,18 @@ static void vda_decoder_callback (void *vda_hw_ctx,
queue_walker = vda_ctx->queue; queue_walker = vda_ctx->queue;
if (!queue_walker || (new_frame->pts < queue_walker->pts)) if (!queue_walker || (new_frame->pts < queue_walker->pts)) {
{
/* we have an empty queue, or this frame earlier than the current queue head */ /* we have an empty queue, or this frame earlier than the current queue head */
new_frame->next_frame = queue_walker; new_frame->next_frame = queue_walker;
vda_ctx->queue = new_frame; vda_ctx->queue = new_frame;
} } else {
else
{
/* walk the queue and insert this frame where it belongs in display order */ /* walk the queue and insert this frame where it belongs in display order */
vda_frame *next_frame; vda_frame *next_frame;
while (1) while (1) {
{
next_frame = queue_walker->next_frame; next_frame = queue_walker->next_frame;
if (!next_frame || (new_frame->pts < next_frame->pts)) if (!next_frame || (new_frame->pts < next_frame->pts)) {
{
new_frame->next_frame = next_frame; new_frame->next_frame = next_frame;
queue_walker->next_frame = new_frame; queue_walker->next_frame = new_frame;
break; break;
@ -219,11 +212,11 @@ int ff_vda_create_decoder(struct vda_context *vda_ctx,
kCVPixelBufferIOSurfacePropertiesKey, kCVPixelBufferIOSurfacePropertiesKey,
io_surface_properties); io_surface_properties);
status = VDADecoderCreate( config_info, status = VDADecoderCreate(config_info,
buffer_attributes, buffer_attributes,
(VDADecoderOutputCallback *)vda_decoder_callback, (VDADecoderOutputCallback *)vda_decoder_callback,
vda_ctx, vda_ctx,
&vda_ctx->decoder ); &vda_ctx->decoder);
CFRelease(height); CFRelease(height);
CFRelease(width); CFRelease(width);
@ -278,8 +271,7 @@ vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx)
void ff_vda_release_vda_frame(vda_frame *frame) void ff_vda_release_vda_frame(vda_frame *frame)
{ {
if (frame) if (frame) {
{
CVPixelBufferRelease(frame->cv_buffer); CVPixelBufferRelease(frame->cv_buffer);
av_freep(&frame); av_freep(&frame);
} }

View File

@ -36,8 +36,7 @@
/** /**
* This structure is used to store a decoded frame information and data. * This structure is used to store a decoded frame information and data.
*/ */
typedef struct typedef struct {
{
/** /**
* The PTS of the frame. * The PTS of the frame.
* *
@ -71,7 +70,6 @@ typedef struct
* The application must make it available as AVCodecContext.hwaccel_context. * The application must make it available as AVCodecContext.hwaccel_context.
*/ */
struct vda_context { struct vda_context {
/** /**
* VDA decoder object. * VDA decoder object.
* *