Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
75be547f
Commit
75be547f
authored
13 years ago
by
Sebastien Zwickert
Browse files
Options
Downloads
Patches
Plain Diff
vda: uses pthreads directly.
parent
5ada64a5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libavcodec/vda.c
+9
-34
9 additions, 34 deletions
libavcodec/vda.c
libavcodec/vda.h
+2
-1
2 additions, 1 deletion
libavcodec/vda.h
with
11 additions
and
35 deletions
libavcodec/vda.c
+
9
−
34
View file @
75be547f
...
...
@@ -26,7 +26,7 @@
#include
<CoreFoundation/CFData.h>
#include
<CoreFoundation/CFString.h>
#include
"
avcodec
.h"
#include
"
libavutil/avutil
.h"
#include
"vda_internal.h"
/**
...
...
@@ -35,27 +35,6 @@
* @{
*/
/* 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
)
{
...
...
@@ -93,7 +72,7 @@ static void vda_clear_queue(struct vda_context *vda_ctx)
{
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
;
...
...
@@ -101,7 +80,7 @@ static void vda_clear_queue(struct vda_context *vda_ctx)
ff_vda_release_vda_frame
(
top_frame
);
}
vda_lock_operation
(
&
vda_ctx
->
queue_mutex
,
AV_LOCK_RELEASE
);
pthread_mutex_unlock
(
&
vda_ctx
->
queue_mutex
);
}
...
...
@@ -130,7 +109,7 @@ static void vda_decoder_callback (void *vda_hw_ctx,
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
;
...
...
@@ -154,7 +133,7 @@ static void vda_decoder_callback (void *vda_hw_ctx,
}
}
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
,
...
...
@@ -174,10 +153,7 @@ 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
;
vda_lock_operation
(
&
vda_ctx
->
queue_mutex
,
AV_LOCK_CREATE
);
pthread_mutex_init
(
&
vda_ctx
->
queue_mutex
,
NULL
);
if
(
extradata
[
4
]
==
0xFE
)
{
// convert 3 byte NAL sizes to 4 byte
...
...
@@ -247,8 +223,7 @@ int ff_vda_destroy_decoder(struct vda_context *vda_ctx)
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
);
...
...
@@ -266,10 +241,10 @@ vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx)
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
;
}
...
...
This diff is collapsed.
Click to expand it.
libavcodec/vda.h
+
2
−
1
View file @
75be547f
...
...
@@ -23,6 +23,7 @@
#ifndef AVCODEC_VDA_H
#define AVCODEC_VDA_H
#include
<pthread.h>
#include
<stdint.h>
// emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
...
...
@@ -92,7 +93,7 @@ struct vda_context {
* - encoding: unused
* - decoding: Set/Unset by libavcodec.
*/
void
*
queue_mutex
;
pthread_mutex_t
queue_mutex
;
/**
* The frame width.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment