Commit graph

71 commits

Author SHA1 Message Date
Hyunjun Ko
45b258127c applemedia: vtenc: fix build break on iOS
Fix 'conflicting types' error
https://bugzilla.gnome.org/show_bug.cgi?id=765292
2016-04-21 09:28:01 +03:00
Hyunjun Ko
5023a7c85d applemedia: vtenc: Fix a warning by weak-link symbol
Fix this warning
address of function 'VTCompressionSessionPrepareToEncodeFrames' will always evaluate to 'true' [-Wpointer-bool-conversion]

https://bugzilla.gnome.org/show_bug.cgi?id=765292
2016-04-20 17:16:02 +03:00
Alessandro Decina
5c7fb644cd applemedia: vtenc: fix build on iOS 2016-01-19 19:18:43 +11:00
Alessandro Decina
f6154b4cc0 applemedia: always fill GstBuffers with GstMemory
Always fill buffers with our custom memory. The custom memory will avoid
mapping CV/CM buffers unless necessary.
2016-01-19 16:13:04 +11:00
Alessandro Decina
e0d65937bc applemedia: vtenc: accept UYVY on Mac
When doing GLMemory avfvideosrc negotiates UYVY. This change allows avfvideosrc
! tee name=t ! ... ! glimagesink t. ! ... ! gldownload ! vtenc_h264 ! ...
to do GLMemory and 0-copy with the encoder (with the CV meta).
2016-01-06 11:43:37 +11:00
Heinrich Fink
788ff2f98e vtenc: Set profile_level to NULL after release
Otherwise, gst_vtenc_negotiate_profile_and_level will double-release as
it checks for profile_level != NULL. This caused crashes when the
vtenc instance is stopped and then restarted.

https://bugzilla.gnome.org/show_bug.cgi?id=757935
2015-11-11 14:49:58 +01:00
Alessandro Decina
5336cc9ff6 Revert "vtenc: free input buffer ASAP"
This reverts commit 6101fc57b8.

GstVideoEncoder assumes that the input buffer is available until _finish_frame.

https://bugzilla.gnome.org/show_bug.cgi?id=756951
2015-11-02 20:16:15 +11:00
Ilya Konstantinov
29c79d7595 vtenc: always enqueue frames, even on error
Even when we fail to encode frame, we should still enqueue it so
it could be passed into handle_frame (with output_buffer == NULL).
Otherwise, we risk GstVideoEncoder's queue of frames growing unbounded.

Note: We're slightly changing the renegotiation code to accommodate for
frames without output buffers, but this commit takes no ownership over
the way negotiation is being done.

https://bugzilla.gnome.org/show_bug.cgi?id=750669
2015-06-10 22:23:06 +02:00
Ilya Konstantinov
6101fc57b8 vtenc: free input buffer ASAP
VTCompressionSessionEncodeFrame retains the CVPixelBuffer during
encoding, and will release it as soon as it can (e.g. before it even
calls our callback). This means we can safely release input buffer
at this point, possibly allowing the system to reuse it sooner.

https://bugzilla.gnome.org/show_bug.cgi?id=750671
2015-06-10 10:30:23 +02:00
Ilya Konstantinov
f5c29c7379 vtenc: Add missing gst_vtenc_frame_free() in error path
https://bugzilla.gnome.org/show_bug.cgi?id=750668
2015-06-10 10:26:28 +02:00
Ilya Konstantinov
5db08a8b89 vtenc: add alignment=au to sink caps
VT compression callback gets a CMSampleBuffer per frame, so vtenc_h264
should set 'alignment=au' in sink caps to indicate this.

https://bugzilla.gnome.org/show_bug.cgi?id=750635
2015-06-10 10:20:44 +02:00
Ilya Konstantinov
faf903720a vtenc: no need for queue_length with try_pop 2015-06-09 16:20:06 +02:00
Ilya Konstantinov
94e7ed1323 vtenc: fix keyframe request race condition
It is incorrect to modify the frame properties after passing them, since
VTCompressionSessionEncodeFrame takes reference and we have no control
over when it's being used.

In fact, the code can be simplified. We just preallocate the frame
properties for keyframe requests, and pass NULL otherwise.

https://bugzilla.gnome.org/show_bug.cgi?id=748467
2015-06-01 13:32:03 +02:00
Sebastian Dröge
0c9f35653f vtenc: Check if VTSessionCopyProperty() succeeds before using the result
https://bugzilla.gnome.org/show_bug.cgi?id=744585
2015-02-16 12:35:09 +02:00
Alessandro Decina
8734abb1ce applemedia: don't call CVPixelBufferLockBaseAddress when doing texture sharing
When doing texture sharing we don't need to call CVPixelBufferLockBaseAddress to
map the buffer in CPU. This cuts about 10% relative cpu time from a vtdec !
glimagesink pipeline.
2015-01-30 00:34:08 +11:00
Alessandro Decina
e91989136a applemedia: corevideobuffer: make mapping the CVPixelBuffer in CPU optional
Mapping is not necessary and impacts performance when doing texture sharing with
downstream
2015-01-30 00:34:08 +11:00
Florian Zwoch
7d318a572c vtenc: Unlock the stream lock while waiting for pending frames to be completed in finish()
We might otherwise deadlock because gst_vtenc_enqueue_buffer() can be
called again and will take the stream lock again from another thread.

https://bugzilla.gnome.org/show_bug.cgi?id=742174
2015-01-08 14:48:20 +01:00
Sebastian Dröge
568da160cb vtenc: Instead of crashing if no corresponding frame is found, ignore this
... and hope that everything will be fine. This shouldn't really happen but
previously happened during shutdown. It should be fixed in videoencoder now,
but better be on the safe side here.
2014-12-22 11:49:08 +01:00
Alessandro Decina
4d89d7116b vtenc: bump rank to PRIMARY 2014-12-11 00:02:26 +11:00
Alessandro Decina
21f8c96d75 vtenc: negotiate profile and level with downstream 2014-12-10 22:36:53 +11:00
Alessandro Decina
8166487a00 vtenc: report latency 2014-12-10 19:44:51 +11:00
Sebastian Dröge
b88e4304f1 vtenc: Add properties to specify the maximum keyframe interval in frames and seconds 2014-12-05 16:33:54 +01:00
Sebastian Dröge
1a2362eb2b vtenc: Fix conversion of the bitrate property and our internal bitrate storage
The property is in kbit/s and we store it in bit/s, so just multiply and
divide by 1000. No need to put a factor of 8 in there.

kVTCompressionPropertyKey_AverageBitRate is also in bit/s according to
its documentation.
2014-12-05 16:17:16 +01:00
Alessandro Decina
d25813c9bc vtenc: add quality property 2014-11-27 18:41:21 +01:00
Alessandro Decina
6a4270d5cc vtenc: set profile and level in caps 2014-11-27 18:41:21 +01:00
Alessandro Decina
d45a2f0480 vtenc: let VT pick the bitrate by default 2014-11-21 15:48:08 +01:00
Alessandro Decina
d800ac023b vtenc: set H264_Baseline_AutoLevel on OSX as well 2014-11-20 16:06:46 +01:00
Alessandro Decina
5977ef5552 vtenc: fix build on iOS 2014-11-12 16:45:12 +01:00
Alessandro Decina
a1cc1b34e1 vtenc: fix compilation on < 10.9 2014-11-12 10:00:11 +01:00
Alessandro Decina
bc7dbd7b51 vtenc: enable the hw encoder on OSX 2014-11-11 18:01:54 +01:00
Alessandro Decina
1d97516731 vtenc: add realtime and allow-frame-reordering properties 2014-11-07 00:22:08 +01:00
Sebastian Dröge
68c067e3c9 vtenc: Fix locking
The object lock only protects the session, as we modify
the session from other threads when the bitrate property
is changed. Don't hold it much longer than for session
related things.

And we need to release the video decoder stream lock before
enqueueing a frames. It might wait for our callback to dequeue
a frame from another thread, which will then take the stream
lock too and deadlock.
2014-10-21 16:22:06 +02:00
Sebastian Dröge
ad649138aa vtenc: Use kVTProfileLevel_H264_Baseline_AutoLevel only on iOS
It is not required on OSX apparently and was only added in 10.9.6 there.
Calculating the correct level from the configuration is not trivial, so let's
just not set a level at all here.
2014-10-19 14:57:43 +02:00
Sebastian Dröge
b57f255f26 vtenc: VTCompressionSessionPrepareToEncodeFrames only exists since 10.9.6
Check with configure for it instead of using one of the availability macros
as those wouldn't work as expected with minor versions.
2014-10-19 14:51:40 +02:00
Sebastian Dröge
e79355078e vtenc: Remove unused #define 2014-10-19 14:32:31 +02:00
Sebastian Dröge
3c1ccb64eb vtenc: Fix encoder to work on iOS
iOS has special stride requirements that we don't know yet, so copy
input buffers into buffers allocated by iOS for now.

Later we should check the stride and probably provide a buffer pool for these
buffers so upstream can directly write in there.
2014-09-19 14:47:05 +03:00
Sebastian Dröge
9380f6282d vtenc: Let the encoder automatically choose a h264 level
We should negotiate these things via caps...
2014-09-18 17:49:46 +03:00
Sebastian Dröge
31476a3c46 vtenc: Use 0 instead of G_MAXDOUBLE as the max keyframe interval
0 means no limit, which was meant here with G_MAXDOUBLE probably.
2014-09-18 13:45:33 +03:00
Sebastian Dröge
8c1e84ff71 vtenc: Expected duration is supposed to be the duration of the stream, not a frame
Just don't set it for now, it isn't really needed.
2014-09-18 13:42:24 +03:00
Sebastian Dröge
61c40523df vtenc: Properly handle keyframes
Especially set the SYNC_POINT flag on keyframes.
2014-09-18 13:11:05 +03:00
Sebastian Dröge
ddea2e4498 vtenc: Prepare encoder after setup
This will allow encoding to happen faster on the first frame.
2014-09-17 17:10:58 +03:00
Sebastian Dröge
c6f17d6013 vtenc: Only drain the encoder in ::finish(), not on every frame
Otherwise quality and bitrate will be bad.
2014-09-17 17:08:57 +03:00
Sebastian Dröge
0390398e39 vtenc: Error out if encoding returned an error
Otherwise we will just continue consuming frames until all memory is filled
up and the app crashes.
2014-09-17 15:39:26 +03:00
Sebastian Dröge
e3bc32fb58 vtenc: Check for errors from VTCompressionSessionCompleteFrames() 2014-09-17 14:56:05 +03:00
Sebastian Dröge
b93e0f5f99 vtenc: Properly scale timestamps for the API and set invalid values 2014-09-17 14:55:24 +03:00
Sebastian Dröge
7fa9bbc3b0 vtenc: Port to GstVideoEncoder base class 2014-09-16 17:04:31 +03:00
Sebastian Dröge
4e1f8285c2 vtenc: Use correct instance struct size 2014-09-16 16:13:16 +03:00
Sebastian Dröge
f2eedb9cee vtenc: Port to the real VideoToolbox API instead of using our dlopen() wrapper
It's a public framework since a long time.
2014-09-16 15:47:29 +03:00
Sebastian Rasmussen
b323fba934 vtenc: Avoid leaking caps object and its copy
gst_pad_get_pad_template_caps() returns a reference which is unreferenced,
so creating a copy using gst_caps_copy() results in a reference leak. Also
the caps are pushed as an event downstream, but this doesn't consume the
caps so it must still be unreferenced.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=734534
2014-08-10 12:13:48 +01:00
Matthieu Bouron
e1601406a5 vtenc: fix memory leak
The pixel buffer release callback is called if the void *
dataPtr given to the CVPixelBufferCreateWithPlanarBytes
is not NULL.

According to the documentation dataPtr is supposed to be a
"plane description block" but no specific type is given.

https://bugzilla.gnome.org/show_bug.cgi?id=711847
2014-06-30 13:09:28 +02:00